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