View source: R/token-azure-identity.R
| foundry_token_azure_identity | R Documentation |
Create a provider function for foundry_set_token_provider() that acquires
Microsoft Entra ID access tokens through the AzureAuth package. This
supports service principals (client secret or certificate), managed identity,
and interactive or device-code flows, and refreshes tokens automatically as
they approach expiry.
foundry_token_azure_identity(
resource = "https://cognitiveservices.azure.com",
tenant = Sys.getenv("AZURE_TENANT_ID"),
app = Sys.getenv("AZURE_CLIENT_ID"),
password = NULL,
username = NULL,
certificate = NULL,
auth_type = NULL,
managed_identity = FALSE,
version = 1,
...
)
resource |
Character. The token audience. Defaults to
|
tenant |
Character. Microsoft Entra ID tenant. Defaults to the
|
app |
Character. Application (client) ID. Defaults to the
|
password |
Character or |
username |
Character or |
certificate |
Character or |
auth_type |
Character or |
managed_identity |
Logical. If |
version |
Integer. Microsoft Entra ID endpoint version, |
... |
Additional arguments passed to |
The token is acquired lazily on first use, so building the provider never triggers a network call. Tokens are re-acquired within five minutes of expiry; AzureAuth reuses its on-disk cache and refresh tokens under the hood, so re-acquisition is inexpensive and does not re-prompt for interactive flows.
A zero-argument token provider function suitable for
foundry_set_token_provider().
foundry_token_azure_cli() for a provider that shells out to the
Azure CLI instead.
# Creating providers is local: no tokens are acquired or credentials checked.
provider <- foundry_token_azure_identity(
tenant = "example-tenant-id",
app = "example-client-id",
password = "example-client-secret-not-a-secret"
)
is.function(provider)
# A managed-identity provider acquires tokens only when called inside Azure.
managed_provider <- foundry_token_azure_identity(managed_identity = TRUE)
is.function(managed_provider)
# Register this provider with scope = "project" for project APIs.
project_provider <- foundry_token_azure_identity(
resource = "https://ai.azure.com",
managed_identity = TRUE
)
is.function(project_provider)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.