| AuthCodeCredential | R Documentation |
Authenticates a user through the OAuth 2.0 authorization code flow. This flow opens a web browser for the user to sign in.
The authorization code flow is the standard OAuth 2.0 flow for interactive authentication. It requires a web browser and is suitable for applications where the user can interact with a browser window.
The credential supports token caching to avoid repeated authentication. Tokens can be cached to disk or in memory. A redirect URI is required for the OAuth flow to complete.
Credential -> InteractiveCredential -> AuthCodeCredential
.redirect_uriCharacter string specifying the redirect URI registered with the application.
Credential$print()Credential$validate()InteractiveCredential$get_token()InteractiveCredential$is_interactive()InteractiveCredential$req_auth()AuthCodeCredential$new()Create a new authorization code credential
AuthCodeCredential$new( scope = NULL, tenant_id = NULL, client_id = default_azure_cli_client_id(), use_cache = "disk", offline = TRUE, redirect_uri = default_redirect_uri(), allow_prompt = TRUE, use_refresh_token = TRUE, interactive = NULL )
scopeA character string specifying the OAuth2 scope. Defaults to NULL.
tenant_idA character string specifying the Azure Active Directory
tenant ID. Defaults to NULL.
client_idA character string specifying the application (client) ID. Defaults to the Azure CLI public client ID.
use_cacheA character string specifying the cache type. Use "disk"
for disk-based caching or "memory" for in-memory caching. Defaults to "disk".
offlineA logical value indicating whether to request offline access
(refresh tokens). Defaults to TRUE.
redirect_uriA character string specifying the redirect URI registered
with the application. Defaults to default_redirect_uri().
allow_promptA logical value indicating whether this credential
may prompt the user (vs. only reading cached/refresh tokens). Defaults
to TRUE.
use_refresh_tokenA logical value indicating whether to use the login flow
(acquire tokens via refresh token exchange). Defaults to TRUE.
interactiveDeprecated. Use allow_prompt instead.
A new AuthCodeCredential object
AuthCodeCredential$clone()The objects of this class are cloneable with this method.
AuthCodeCredential$clone(deep = FALSE)
deepWhether to make a deep clone.
# AuthCodeCredential requires an interactive session
## Not run:
# Create credential with default settings
cred <- AuthCodeCredential$new(
tenant_id = "your-tenant-id",
client_id = "your-client-id",
scope = "https://management.azure.com/.default"
)
# Get an access token (will open browser for authentication)
token <- cred$get_token()
# Force reauthentication
token <- cred$get_token(reauth = TRUE)
# Use with httr2 request
req <- httr2::request("https://management.azure.com/subscriptions")
req <- cred$req_auth(req)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.