provenaclient.auth.manager

Created Date: Monday June 17th 2024 +1000 Author: Peter Baker —– Last Modified: Monday June 17th 2024 4:45:39 pm +1000 Modified By: Peter Baker —– Description: Auth Manager interface which defines key methods for authorising API requests in the provena client —– HISTORY: Date By Comments ———- — ———————————————————

Attributes

LogType

DEFAULT_LOG_LEVEL

Classes

Log

Create a collection of name/value pairs.

AuthManager

Helper class that provides a standard way to create an ABC using

Module Contents

class provenaclient.auth.manager.Log(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

DEBUG = 10
INFO = 20
WARNING = 30
ERROR = 40
provenaclient.auth.manager.LogType
provenaclient.auth.manager.DEFAULT_LOG_LEVEL
class provenaclient.auth.manager.AuthManager(log_level: LogType | None = None)[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

logger: logging.Logger
abstract get_token() str[source]

Get token information and other metadata.

abstract force_refresh() None[source]

Force refresh the current token

get_auth() provenaclient.auth.helpers.HttpxBearerAuth[source]

A helper function which produces a BearerAuth object for use in the httpx library. For example:

manager = DeviceFlow(…) auth = manager.get_auth httpx.post(…, auth=auth)

Returns:

The httpx auth object.

Return type:

BearerAuth

Raises:
  • Exception – Raises exception if tokens/public_key are not setup - make sure that the object is instantiated properly before calling this function.

  • Exception – If the token is invalid and cannot be refreshed.

  • Exception – If the token validation still fails after re-conducting the device flow.