logicly / easy-oauth-client
适用于Laravel的多功能OAuth2客户端
v1.0.1
2024-04-16 21:11 UTC
Requires
- php: ^8.1
- illuminate/support: >7
Requires (Dev)
README
多功能OAuth2客户端,通过配置文件可配置用于多个提供者。
安装
通过Composer
$ composer require logicly/easy-oauth-client
使用
发布配置
$ php artisan provider:publish --provider="Logicly\EasyOAuthClient\EasyOAuthClientServiceProvider"
使用提供的示例配置配置配置文件。
然后按照以下方式使用包
use Logicly\EasyOAuthClient\Client; // ... $oAuthClient = new Client("providername"); // Returns array defined in config $response = $oAuthClient->getToken($code); //Returns array defined in config $response = $oAuthClient->getInfo($accesstoken); //Returns array defined in config $response = $oAuthClient->refreshToken($refreshtoken);
配置
提供配置示例,编辑值以匹配提供者规范
<?php return [ 'provider1' => [ 'client_id' => '1234', 'client_secret' => '12345', 'redirect_uri' => 'https://www.example.com/oauth2/provider1', 'token' => [ 'url' => 'https://login.provider.example.com/oauth2/token', 'method' => 'POST', 'grant_type' => 'authorization_code', 'fields' => [ 'access_token' => 'access_token', 'expires_in' => 'expires_in', 'refresh_token' => 'refresh_token', ], 'auth' => 'body', ], 'refresh' => [ 'url' => 'https://login.provider.example.com/oauth2/token', 'method' => 'POST', 'grant_type' => 'authorization_code', 'fields' => "*", 'auth' => 'body', ], 'info' => [ 'url' => 'https://login.provider.example.com/oauth2/metadata', 'method' => 'GET', 'fields' => [ 'metadata1', 'metadata2', ], ], ], 'provider2' => ['...'], ];
变更日志
请参阅 变更日志 了解最近更改的详细信息。
测试
$ composer test
安全
如果您发现任何安全问题,请通过作者电子邮件而不是问题跟踪器来联系作者。