module documentation

This module implements OAuth token retrieval.

Function getOAuthToken Retrieve and return a oauth2 token. If there is a provided token that is still valid, then that token is returned.
Variable Token A named tuple for a token.
Variable _expirationLeeway Leeway for token expiration.
def getOAuthToken(serverURL: str, clientID: str, clientSecret: str, token: Token | None = None, kind: str | None = 'keycloak') -> Token | None:

Retrieve and return a oauth2 token. If there is a provided token that is still valid, then that token is returned.

This function returns a new named tuple Token(token, expiration), or None in case of an error. The expiration is in epoch seconds.

Parameters
serverURL:strThe URL of the OAuth server.
clientID:strThe client ID.
clientSecret:strThe client secret.
token:Token | NoneOptional token to check if it is still valid.
kind:str | NoneThe kind of OAuth server. Currently only 'keycloak' is supported.
Returns
Token | NoneA Token tuple or None in case of an error.
Token =

A named tuple for a token.

_expirationLeeway: float =

Leeway for token expiration.