micro/plugin-oauth2-client
最新稳定版本:v2.0.0-alpha1
Composer 安装命令:
composer require micro/plugin-oauth2-client
包简介
Micro Framework: OAuth2 client based on "league/oauth2-client"
README 文档
README
Micro Framework: OAuth2 client based on "league/oauth2-client"
Installation
Install plugin with composer
$ composer require micro/plugin-oauth2-client
And install a specific provider(s).
Available providers: micro/plugin-oauth2-client-keycloak
Аnd then add plugin to the list of plugins (etc/plugins.php)
$pluginsCommon = [ //....OTHER PLUGINS .... Micro\Plugin\OAuth2\Client\OAuth2ClientPlugin::class, Micro\Plugin\OAuth2\Client\Keycloak\OAuth2KeycloakProviderPlugin::class, ];
Configure your oauth2 providers
The adapter configuration template usually looks like this MICRO_OAUTH2_<PROVIDER_NAME>_<PROVIDER_SETTING>
Default adapter name "default"
MICRO_OAUTH2_DEFAULT_TYPE=keycloak MICRO_OAUTH2_DEFAULT_CLIENT_ID=<my-client-id> MICRO_OAUTH2_DEFAULT_CLIENT_SECRET=<client-secret-key> MICRO_OAUTH2_DEFAULT_CLIENT_URL_AUTHORIZATION=<auth url> MICRO_OAUTH2_DEFAULT_CLIENT_URL_REDIRECT=<redirect url>
Usage/Examples
Index document
use use Micro\Plugin\OAuth2\Client\Facade\Oauth2ClientFacadeInterface; /** Unauthorized user */ $client = $container->get(Oauth2ClientFacadeInterface::class); $provider = $client->getProvider('default'); $provider->getAuthorizationUrl(); This method will return the full path to the server for user authorization. /*** Response from the authorization server with a code */ $accessToken = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'], ]); $owner = $provider->getResourceOwner($accessToken); $id = $owner->getId(); $ownerData = $owner->toArray(); //Associated data with the user.
Support
For support, email head.trackingsoft@gmail.com.
Authors
License
统计信息
- 总下载量: 370
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-25