| RefreshTokenCredential | R Documentation |
Authenticates using an existing refresh token. This credential is useful when you have obtained a refresh token through another authentication flow and want to use it to get new access tokens without interactive authentication.
The refresh token credential uses the OAuth 2.0 refresh token flow to obtain new access tokens. It requires a valid refresh token that was previously obtained through an interactive flow (e.g., authorization code or device code).
This is particularly useful for:
Non-interactive sessions where you have a pre-obtained refresh token
Long-running applications that need to refresh tokens automatically
Scenarios where you want to avoid repeated interactive authentication
azr::Credential -> RefreshTokenCredential
.refresh_tokenCharacter string containing the refresh token.
new()Create a new refresh token credential
RefreshTokenCredential$new( refresh_token = default_refresh_token(), scope = NULL, tenant_id = NULL, client_id = NULL )
refresh_tokenA character string containing the refresh token.
Defaults to default_refresh_token() which reads from the
AZURE_REFRESH_TOKEN environment variable.
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 NULL.
A new RefreshTokenCredential object
validate()Validate the credential configuration
RefreshTokenCredential$validate()
Checks that the refresh token is provided and not NA or NULL. Calls the parent class validation method.
get_token()Get an access token using the refresh token flow
RefreshTokenCredential$get_token()
An httr2::oauth_token() object containing the access token
req_auth()Add OAuth refresh token authentication to an httr2 request
RefreshTokenCredential$req_auth(req)
reqAn httr2::request() object
The request object with OAuth refresh token authentication configured
clone()The objects of this class are cloneable with this method.
RefreshTokenCredential$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run:
# Create credential with a refresh token
cred <- RefreshTokenCredential$new(
refresh_token = "your-refresh-token",
scope = "https://management.azure.com/.default",
tenant_id = "your-tenant-id",
client_id = "your-client-id"
)
# Get an access token
token <- cred$get_token()
# Use with httr2 request
req <- httr2::request("https://management.azure.com/subscriptions")
resp <- httr2::req_perform(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.