Authentication
get_access_token
get_access_token(audience: str) -> str
Retrieves an access token for a given audience.
This function attempts to obtain an access token for a given audience.
It first checks if the code is running in a Microsoft Fabric notebook environment
and attempts to use the notebookutils
library to get the token. If the library
is not available, it falls back to using the DefaultAzureCredential
from the Azure SDK
to fetch the token.
get_onelake_access_token
get_onelake_access_token() -> str
Alias for get_azure_storage_access_token
get_azure_storage_access_token
get_azure_storage_access_token() -> str
Retrieves an access token for Azure Storage.
This function attempts to obtain an access token for accessing Azure storage.
It first checks if the AZURE_STORAGE_TOKEN
environment variable is set.
Otherwise, it tries to get the token using notebookutils.credentials.getToken
.
Lastly, it falls back to using the DefaultAzureCredential
.
Returns:
Type | Description |
---|---|
str
|
The access token used for authenticating requests to Azure Storage. |
get_fabric_bearer_token
get_fabric_bearer_token() -> str
Retrieves a bearer token for Fabric (Power BI) API.
This function attempts to obtain a bearer token for authenticating requests to the
Power BI API. It first checks if the code is running in a Microsoft Fabric
notebook environment and tries to use the notebookutils
library to get the token.
If the library is not available, it falls back to using the DefaultAzureCredential
from the Azure SDK to fetch the token.
Returns:
Type | Description |
---|---|
str
|
The bearer token used for authenticating requests to the Fabric (Power BI) API. |
get_azure_devops_access_token
get_azure_devops_access_token() -> str
Retrieves a bearer token for Azure DevOps.
This function attempts to obtain a bearer token for authenticating requests to Azure DevOps.
Returns:
Type | Description |
---|---|
str
|
The bearer token used for authenticating requests to Azure DevOps. |
get_storage_options
get_storage_options() -> dict[str, str]
Retrieves storage options including a bearer token for Azure Storage.
This function calls get_azure_storage_access_token
to obtain a bearer token
and returns a dictionary containing the token.
Returns:
Type | Description |
---|---|
dict[str, str]
|
A dictionary containing the storage options for Azure Storage. |
Example
Retrieve storage options
from msfabricutils import get_storage_options
options = get_storage_options()
options
{"bearer_token": "your_token_here"}