Skip to content

Authentication

Authentication token providers for connector clients.

Classes

TokenProvider

Bases: ABC

Interface for providing authentication tokens.

Methods:

get_access_token_async abstractmethod async
get_access_token_async(scopes: List[str]) -> str

Get an access token for the specified scopes.

Parameters:

Name Type Description Default
scopes List[str]

The authentication scopes.

required

Returns:

Type Description
str

The access token.

AzureIdentityTokenProvider

AzureIdentityTokenProvider(credential: Any)

Bases: TokenProvider

Token provider that wraps Azure Identity async credentials.

Initialize an AzureIdentityTokenProvider.

Parameters:

Name Type Description Default
credential Any

An Azure Identity async credential (e.g., DefaultAzureCredential from azure.identity.aio). Must have an async get_token() method.

required

Methods:

get_access_token_async async
get_access_token_async(scopes: List[str]) -> str

Get an access token using the Azure Identity credential.

close async
close()

Close the underlying credential.

ManagedIdentityTokenProvider

ManagedIdentityTokenProvider(client_id: Optional[str] = None)

Bases: TokenProvider

Token provider using Azure Managed Identity.

Initialize a new ManagedIdentityTokenProvider.

Parameters:

Name Type Description Default
client_id Optional[str]

Optional client ID for user-assigned managed identity.

None

Methods:

get_access_token_async async
get_access_token_async(scopes: List[str]) -> str

Get an access token using managed identity.

close async
close()

Close the underlying credential.

ConnectionStringTokenProvider

ConnectionStringTokenProvider(api_key: str)

Bases: TokenProvider

Token provider using a pre-configured connection string or API key.

Initialize a new ConnectionStringTokenProvider.

Parameters:

Name Type Description Default
api_key str

The API key or connection string.

required

Methods:

get_access_token_async async
get_access_token_async(scopes: List[str]) -> str

Return the API key directly (no token acquisition needed).