foundry_dev_tools.config.token_provider module#

The Foundry DevTools Token providers.

class foundry_dev_tools.config.token_provider.TokenProvider[source]#

Bases: object

The TokenProvider base class.

Parameters:

host – the foundry host

__init__(host)[source]#

The TokenProvider base class.

Parameters:

host (Host | str) – the foundry host

property token#

Returns the token from the provider.

requests_auth_handler(r)[source]#

Sets bearer authentication header on PreparedRequest object.

Does not overwrite authorization header if present.

Parameters:

r (PreparedRequest)

Return type:

PreparedRequest

class foundry_dev_tools.config.token_provider.JWTTokenProvider[source]#

Bases: TokenProvider

Initialize the JWTTokenProvider.

Parameters:
  • host – the foundry host

  • jwt – the jwt token

__init__(host, jwt)[source]#

Initialize the JWTTokenProvider.

Parameters:
  • host (Host | str) – the foundry host

  • jwt (Token) – the jwt token

Return type:

None

property token: Token#

Returns the token supplied when creating this Provider.

class foundry_dev_tools.config.token_provider.CachedTokenProvider[source]#

Bases: TokenProvider

The TokenProvider base class.

Parameters:

host – the foundry host

invalidate_cache()[source]#

Invalidates the token cache.

property token: Token#

Returns the token from a dynamic source and caches it.

class foundry_dev_tools.config.token_provider.OAuthTokenProvider[source]#

Bases: CachedTokenProvider

Provides tokens via the OAuth authentication.

Parameters:
  • host – the foundry host

  • client_id – the client ID

  • client_secret – the client secret, optional if the grant_type is authorization_code, and mandatory if the grant_type is client_credentials

  • grant_type – the OAuth grant type, see FoundryOAuthGrantType

  • scopes – if the grant_type is authorization_code and not set it will default to DEFAULT_OAUTH_SCOPES, if the grant_type is client_credentials the scopes provided will be used, per default these are null

__init__(host, client_id, client_secret=None, grant_type=None, scopes=None)[source]#

Provides tokens via the OAuth authentication.

Parameters:
  • host (Host | str) – the foundry host

  • client_id (str) – the client ID

  • client_secret (str | None) – the client secret, optional if the grant_type is authorization_code, and mandatory if the grant_type is client_credentials

  • grant_type (FoundryOAuthGrantType | None) – the OAuth grant type, see FoundryOAuthGrantType

  • scopes (list[str] | str | None) – if the grant_type is authorization_code and not set it will default to DEFAULT_OAUTH_SCOPES, if the grant_type is client_credentials the scopes provided will be used, per default these are null

Return type:

None

class foundry_dev_tools.config.token_provider.AppServiceTokenProvider[source]#

Bases: CachedTokenProvider

The TokenProvider base class.

Parameters:

host – the foundry host

header: ClassVar[str] = 'X-Foundry-AccessToken'#
__init__(host)[source]#

The TokenProvider base class.

Parameters:

host (Host | str) – the foundry host