plutus / oauth2-client-plutus
此包最新版本(v1.2.1)没有提供许可证信息。
PHP League OAuth2-Client 的 Plutus 2.0 客户端提供者
v1.2.1
2021-06-22 08:28 UTC
Requires
- php: >=7.3
- league/oauth2-client: ^2.0
Requires (Dev)
- eloquent/phony-phpunit: ^6.0 || ^7.1
- php-parallel-lint/php-parallel-lint: ^1.3
- phpro/grumphp: ^1.3
- phpunit/phpunit: ^8.0 || ^9.0
- squizlabs/php_codesniffer: ^3.0
README
此包为使用 league/oauth2-client 包提供 Plutus 商业 OAuth 2.0 服务提供程序和令牌。
OAuth 2.0 登录流程,常见于网页中的“使用 Facebook/Google 等连接”按钮,是常添加到 Web 应用的常见集成。`league/oauth2-client` 包提供与各种 OAuth 2.0 提供程序的集成基础,而不会让您的应用过度负担 RFC 6749 的问题。
要求
我们支持以下版本的 PHP
- PHP 8.0
- PHP 7.4
- PHP 7.3
安装
composer require plutus/oauth2-client-plutus
示例
授权流程
use League\OAuth2\Client\Provider\PlutusProvider;
use League\OAuth2\Client\Token\PlutusAccessToken;
$options = [
'clientId' => 'sso_client_id', // The client ID assigned to you by the provider
'clientSecret' => 'sso_client_secret', // The client password assigned to you by the provider
'redirectUri' => 'sso_redirect_url',
'identityServer' => 'sso_public_url',
];
$this->provider = new PlutusProvider($options);
获取授权 URL
$authorizationUrl = $this->provider->getAuthorizationUrl();
从授权码获取访问令牌
$grant = new AuthorizationCode();
$accessToken = $this->provider->getAccessToken($grant, [
'code' => $request->get('code'),
]);
从刷新令牌获取访问令牌
$grant = new RefreshToken();
$accessToken = $this->provider->getAccessToken($grant, [
'refresh_token' => $token->getRefreshToken(), // token is instance of PlutusAccessToken
]);
获取用户信息
$this->provider->getResourceOwner($accessToken) // instance of PlutusAccessToken
获取 JWKS
$this->provider->getJwks()