steinbauerit/azure-auth-php-client

此包的最新版本(1.0.0)没有可用的许可证信息。

适用于Azure身份验证的PHP客户端

1.0.0 2024-08-01 08:03 UTC

This package is not auto-updated.

Last update: 2024-09-27 10:07:46 UTC


README

适用于Azure身份验证的PHP客户端

安装

只需运行

composer require steinbauerit/azure-auth-php-client

使用方法

try {
    $clientId = 'clientId';
    $clientSecret = 'secret';
    $authorizationCode = 'authCode';

    $tenantId = 'common';
    $redirectUri = 'https://';

    // 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();
}

作者