Authentication

class flame_hub.auth.PasswordAuth(username: str, password: str, base_url: str = 'https://auth.privateaim.dev', client: Client = None)

Bases: Auth

Password authentication for the FLAME Hub.

This class implements a password authentication flow which is one possible flow that is recognized by the FLAME Hub. It is derived from the httpx base class for all authentication flows httpx.Auth. For more information about this base class, click here. Note that base_url is ignored if you pass your own client via the client keyword argument. An instance of this class could be used for authentication to access the Hub endpoints via the clients.

Parameters:
usernamestr

The user’s name which is used to execute the authentication flow.

passwordstr

The password which corresponds to username.

base_urlstr, default=DEFAULT_AUTH_BASE_URL

The base URL for the authentication flow.

clienthttpx.Client

Pass your own client to avoid the instantiation of a client while initializing an instance of this class.

_update_token(token: RefreshToken, request_nanos: int)

Overwrites the current token and calculates the expiring point in time for the new token.

Parameters:
tokenRefreshToken

A new refresh token which replaces the current token.

request_nanosint

The point in time where the request was sent that had token as a response. The unit of this argument needs to be nanoseconds.

See also

RefreshToken
auth_flow(request) Iterator[Request]

Executes the password authentication flow.

If there is no token set, this method requests a new refresh token by using username and password. If the token is just expired, the current token is used to request a new one so that the old one can be replaced by the new refresh token. It then yields the authentication request. Click here for further information on this method.

See also

RefreshToken
class flame_hub.auth.RobotAuth(robot_id: str, robot_secret: str, base_url: str = 'https://auth.privateaim.dev', client: Client = None)

Bases: Auth

Robot authentication for the FLAME Hub.

This class implements a robot authentication flow which is one possible flow that is recognized by the FLAME Hub. It is derived from the httpx base class for all authentication flows httpx.Auth. For more information about this base class, click here. Note that base_url is ignored if you pass your own client via the client keyword argument. An instance of this class could be used for authentication to access the Hub endpoints via the clients.

Parameters:
robot_idstr

The ID of the robot which is used to execute the authentication flow.

robot_secretstr

The secret which corresponds to the robot with ID robot_id.

base_urlstr, default=DEFAULT_AUTH_BASE_URL

The base URL for the authentication flow.

clienthttpx.Client

Pass your own client to avoid the instantiation of a client while initializing an instance of this class.

auth_flow(request) Iterator[Request]

Executes the robot authentication flow.

This method checks if the current access token is not set or expired and, if so, requests a new one from the Hub instance. It then yields the authentication request. Click here for further information on this method.

See also

AccessToken