Skip to main content

authentication_flow

Authentication flow and session management.

Classes

AuthEnvironmentError

class AuthEnvironmentError(*args, **kwargs):

Exception related to the authorization and authentication environment.

Ancestors

BitfountSession

class BitfountSession(authentication_handler: Optional[AuthenticationHandler] = None):

Manages session-based interactions with Bitfount.

Extends requests.Session, appending an access token to the authorization of any requests made if an access token is present

When the token expires it will request a new token prior to sending the web request.

Ancestors

Variables

  • am_request_headers : Dict - Returns metadata for authenticating with message service.
  • authenticated : bool - Returns true if we have an unexpired access token or API Keys.
  • hub_request_headers : Dict - Returns metadata for authenticating with message service.
  • message_service_metadata : List[Tuple[str, str]] - Returns metadata for authenticating with message service.
  • username : str - Returns the username of the authenticated user.

Methods


authenticate

def authenticate(self)> None:

Authenticates user to allow protected requests.

Prompts the user to login/authenticate and stores the tokens to use them in future requests.

Raises

  • AssertionError: If user storage path corresponds to a different username from the BitfountSession.
  • ConnectionError: If a token cannot be retrieved.

request

def request(    self, method, url, params=None, data=None, headers=None, **kwargs,)> Response:

Performs an HTTP request.

Overrides requests.session.request, appending our access token to the request headers or API keys if present.