src.ska_src_api_accounting.oauth2.oauth2_token

Module for handling OAuth2 service token retrieval and caching.

This module defines the OAuth2ServiceToken class, which is responsible for obtaining and caching OAuth2 service tokens using the client credentials grant type. It supports customizable scopes, audiences, and caching strategies to optimize token reuse and minimize redundant token requests.

Module Contents

Classes

OAuth2ServiceToken

A base class for retrieving service tokens. This allows for different clients to be used & parameters to be

class src.ska_src_api_accounting.oauth2.oauth2_token.OAuth2ServiceToken(shortname, default_scopes, audience, client, iam_token_endpoint, try_use_cache=True, cache=None, cache_key_prefix='X', additional_scopes=None, logger=src_logger)

Bases: abc.ABC

A base class for retrieving service tokens. This allows for different clients to be used & parameters to be easily modified and restricted, e.g. scope locked storage.[read|write|modify]:/* tokens for download and upload.

async get(force_renew=False)

Retrieve an access token for the configured OAuth2 client.

If caching is enabled and a valid token exists in the cache, it will be returned. Otherwise, a new token will be requested from the IAM token endpoint using client credentials.