| DeviceCodeCredential | R Documentation |
Authenticates a user through the device code flow. This flow is designed for devices that don't have a web browser or have input constraints.
The device code flow displays a code that the user must enter on another device with a web browser to complete authentication. This is ideal for CLI applications, headless servers, or devices without a browser.
The credential supports token caching to avoid repeated authentication. Tokens can be cached to disk or in memory.
azr::Credential -> azr::InteractiveCredential -> DeviceCodeCredential
new()Create a new device code credential
DeviceCodeCredential$new( scope = NULL, tenant_id = NULL, client_id = NULL, use_cache = "disk", offline = TRUE, interactive = TRUE )
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.
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.
interactiveA logical value indicating whether this credential
requires user interaction. Defaults to TRUE.
A new DeviceCodeCredential object
get_token()Get an access token using device code flow
DeviceCodeCredential$get_token(reauth = FALSE)
reauthA logical value indicating whether to force reauthentication.
Defaults to FALSE.
An httr2::oauth_token() object containing the access token
req_auth()Add OAuth device code authentication to an httr2 request
DeviceCodeCredential$req_auth(req)
reqAn httr2::request() object
The request object with OAuth device code authentication configured
clone()The objects of this class are cloneable with this method.
DeviceCodeCredential$clone(deep = FALSE)
deepWhether to make a deep clone.
# DeviceCodeCredential requires an interactive session
## Not run:
# Create credential with default settings
cred <- DeviceCodeCredential$new()
# Get an access token (will prompt for 'device code' flow)
token <- cred$get_token()
# Force re-authentication
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.