# Create credential with client secret
cred <- ClientSecretCredential$new(
tenant_id = "your-tenant-id",
client_id = "your-client-id",
client_secret = "your-client-secret",
scope = "https://management.azure.com/.default"
)
# To get a token or authenticate a request it requires
# valid 'client_id' and 'client_secret' credentials,
# otherwise it will return an error.
if (FALSE) {
# 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))
}
Run the code above in your browser using DataLab