Authorizer

exception puddle.client.auth.authorizer.AuthError

Bases: Exception

Authentication error.

class puddle.client.auth.authorizer.Authorizer(server_address, api_key_id=None, api_secret_key=None, verify=True)

Bases: puddle.client.auth.base_authorizer.BaseAuthorizer

PUDDLE_API_KEY_ID_ENV_VAR_NAME = 'PUDDLE_api_key_id'

Environment variable from which the api key id is read.

PUDDLE_API_SECRET_KEY_ENV_VAR_NAME = 'PUDDLE_api_secret_key'

Environment variable from which the api secret key is read.

PUDDLE_TOKEN_HEADER = 'X-Puddle-Token'
headers()
Return type

dict

Returns

Dict with all required headers, including auth header.

login()

Executes the login to Puddle.

logout()

Logs out from Puddle.

request_hook(url, body, headers)

This gets invoked before a request is made. This is a good place to make sure that for example auth tokens are valid. :type url: str :param url: :type body: bytes :param body: :type headers: dict :param headers:

response_hook(resp)

This gets invoked after obtaining a response from server. This is a good place to read the response headers for example. :type resp: HTTPResponse :param resp:

property server_address
Return type

str

Returns

Backend server address used by this Authorizer.

property token
Return type

Optional[str]

Returns

Puddle auth token, might be None.