| get_manual_token | R Documentation |
Create an Azure token object from a pre-existing access token string. This is useful when you have obtained a token externally (e.g., via Azure CLI, Python, or another authentication mechanism) and want to use it with the AzureR ecosystem.
get_manual_token(token, type = "Bearer", tenant = NULL, resource = NULL)
token |
A character string containing the access token. |
type |
The token type, usually "Bearer". |
tenant |
Optional tenant ID. If NULL, will be extracted from JWT claims if possible. |
resource |
Optional resource/audience URL or GUID. If NULL, will be extracted from JWT claims if possible. |
This function creates an AzureManualToken object that wraps an externally-obtained
access token. The token object can then be used with packages like AzureGraph,
AzureRMR, and other AzureR family packages.
If the provided token is a JWT (JSON Web Token), the function will attempt to parse it
to extract metadata like tenant ID, resource, and expiration time. For opaque tokens
or tokens that cannot be parsed, you can provide the tenant and resource
parameters manually.
An object of class AzureManualToken, inheriting from AzureToken.
Common ways to obtain tokens externally include:
Azure CLI: az account get-access-token --resource <resource>
Azure PowerShell: Get-AzAccessToken -ResourceUrl <resource>
Python (azure-identity): DefaultAzureCredential().get_token(<scope>)
MSAL libraries in various languages
Manual tokens have the following limitations compared to tokens obtained via
get_azure_token:
Cannot be automatically refreshed when they expire
Are not cached to disk
May have incomplete metadata if JWT parsing fails
AzureManualToken, get_azure_token, decode_jwt
## Not run:
# Example: Use a token from Azure CLI
# First, get the token from command line:
# az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv
raw_token <- "eyJ0eXAiOiJKV1QiLC..."
token <- get_manual_token(raw_token)
# Check token properties
print(token)
token$validate()
# Use with AzureGraph
library(AzureGraph)
gr <- ms_graph$new(token = token)
# For opaque tokens, provide metadata explicitly
token2 <- get_manual_token(
token = "opaque_token_string",
tenant = "your-tenant-id",
resource = "https://management.azure.com/"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.