| ClientSecretCredential | R Documentation |
Authenticates a service principal using a client ID and client secret. This credential is commonly used for application authentication in Azure.
The credential uses the OAuth 2.0 client credentials flow to obtain access tokens. It requires a registered Azure AD application with a client secret. The client secret should be stored securely and not hard-coded in scripts.
azr::Credential -> ClientSecretCredential
validate()Validate the credential configuration
ClientSecretCredential$validate()
Checks that the client secret is provided and not NA or NULL. Calls the parent class validation method.
get_token()Get an access token using client credentials flow
ClientSecretCredential$get_token()
An httr2::oauth_token() object containing the access token
req_auth()Add OAuth client credentials authentication to an httr2 request
ClientSecretCredential$req_auth(req)
reqAn httr2::request() object
The request object with OAuth client credentials authentication configured
clone()The objects of this class are cloneable with this method.
ClientSecretCredential$clone(deep = FALSE)
deepWhether to make a deep clone.
# 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.
## Not run:
# 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.