steinbauerit / azure-auth-php-client
There is no license information available for the latest version (1.0.0) of this package.
PHP client for azure authentication
1.0.0
2024-08-01 08:03 UTC
Requires
- microsoft/kiota-abstractions: ^1.4
- microsoft/kiota-authentication-phpleague: ^1.2
- microsoft/kiota-http-guzzle: ^1.3
- microsoft/kiota-serialization-form: ^1.1.0
- microsoft/kiota-serialization-json: ^1.3
- microsoft/kiota-serialization-multipart: ^1.0.0
- microsoft/kiota-serialization-text: ^1.1
- nyholm/psr7: ^1.8
- symfony/http-client: ^6.4
This package is not auto-updated.
Last update: 2025-01-31 11:42:00 UTC
README
PHP client for azure authentication
Installation
Just run
composer require steinbauerit/azure-auth-php-client
Usage
try {
$clientId = 'clientId';
$clientSecret = 'secret';
$authorizationCode = 'authCode';
$tenantId = 'common';
$redirectUri = 'http://localhost';
// The auth provider will only authorize requests to
// the allowed hosts, in this case Microsoft Graph
$allowedHosts = ['graph.microsoft.com'];
$scopes = ['User.Read'];
$tokenRequestContext = new AuthorizationCodeContext(
$tenantId,
$clientId,
$clientSecret,
$authorizationCode,
$redirectUri
);
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes, $allowedHosts);
$requestAdapter = new GuzzleRequestAdapter($authProvider);
$client = new GraphApiClient($requestAdapter);
$me = $client->me()->get()->wait();
echo "Hello {$me->getDisplayName()}, your ID is {$me->getId()}";
} catch (ApiException $ex) {
echo $ex->getMessage();
}