Skip to main content
Version: 1.10.0

Authentication API

Use this API to provision an authenticated session with the EGS Controller.

Syntax

egs.authenticate(<endpoint>, <api_key>, sdk_default=false)

The authentication session object should be used in all subsequent SDK operations.

Parameters

ParameterParameter TypeDescriptionRequired
<endpoint>StringThe endpoint to the EGS Core APIs service from Kubernetes cluster where the EGS Core APIs deployment is running.Mandatory
<api_key>StringThe API key provided to the end-user to interact with the EGS Controller.Mandatory
sdk_defaultBooleanThe default value is false. Setting this parameter to true will make the provisioned authenticated session as the default session that will be used by other SDK operations, which are provided without authenticated session. When it is set to false, the authenticated session is not treated as SDK default. The returned authenticated session must be passed in subsequent SDK operations.Optional

Response Object Returned

ReturnsDescription
class AuthenticatedSessionThe object of the AuthenticatedSession class containing all the relevant fields and operations required to successfully authenticate with the EGS Controller.

Exceptions Raised

ExceptionDescription
exceptions.ServerUnreachableThis exception is raised when the EGS Core APIs endpoint is not reachable from the Python environment.
exceptions.ApiKeyNotFoundThis exception is raised when the provided API key is not found on the EGS Controller.
exceptions.ApiKeyExpiredThis exception is raised when the provided API key has expired.
exceptions.ApiKeyInvalidThis exception is raised when the provided API key is found, but role information is not properly associated with the API key.

Example

import egs
from egs.exceptions import ApiKeyInvalid, ApiKeyNotFound

try:
# Authenticate the EGS
auth = egs.authenticate("https://egs-core-apis.example.com", "5067bd55-1aef-4c84-8987-3e966e917f07")
print(auth)
except ApiKeyInvalid as e:
# Do something when API key is not found
print("API Key is Invalid")
print(e)
except ApiKeyNotFound as e:
# Do something when API key is not found
print("API Key not found")
print(e)
except Exception as e:
print(e)
print(f"Exception: {e}")