Azure::AD::ClientCredentials - Azure AD Client Credentials authentication flow
use Azure::AD::ClientCredentials; my $creds = Azure::AD::ClientCredentials->new( resource_id => 'https://management.core.windows.net/', client_id => '', secret_id => '', tenant_id => '', ); say $creds->access_token;
Implements the Azure AD Client Credentials flow. See Azure::AD::Auth for more information and alternative flows.
The URL for which you want a token extended (the URL of the service which you want to obtain a token for).
https://graph.windows.net/ for using the MS Graph API
https://graph.windows.net/
https://management.core.windows.net/ for using the Azure Management APIs
https://management.core.windows.net/
The ID of the Azure Active Directory Tenant
The Client ID (also referred to as the Application ID) of an application
A Key assigned to the Client Id.
This defaults to https://login.microsoftonline.com, and generally doesn't need to be specified. Azure AD has more endpoints for some clouds:
https://login.microsoftonline.com
https://login.chinacloudapi.cn China Cloud
https://login.chinacloudapi.cn
https://login.microsoftonline.us US Gov Cloud
https://login.microsoftonline.us
https://login.microsoftonline.de German Cloud
https://login.microsoftonline.de
Returns the access token that has to be sent to the APIs you want to access. This is normally sent in the Authentication header of HTTPS requests as a Bearer token.
The access_token is cached in the object as long as it's valid, so subsequent calls to access_token will return the appropiate token without reauthenticating to Azure AD. If the token has expired, access_token will call Azure AD to obtain a new token transparently.
Example usage:
my $auth = Azure::AD::ClientCredentials->new(...); use HTTP::Tiny; my $ua = HTTP::Tiny->new; my $response = $ua->get( 'http://aservice.com/orders/list', { headers => { Authorization => 'Bearer ' . $auth->access_token } } );
Azure::AD::Auth
Copyright (c) 2018 by CAPSiDE This code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module.
To install Azure::AD::Auth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Azure::AD::Auth
CPAN shell
perl -MCPAN -e shell install Azure::AD::Auth
For more information on module installation, please visit the detailed CPAN module installation guide.