# DeviceCodeCredential requires an interactive session
if (FALSE) {
# 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)
}
Run the code above in your browser using DataLab