werk365 / laraveloauthclient
适用于Laravel的多种用途OAuth客户端
1.0.5
2022-05-27 11:23 UTC
Requires
- illuminate/support: ~7|~8|~9
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
This package is auto-updated.
Last update: 2024-08-27 16:19:37 UTC
README
多功能OAuth客户端,可以通过配置文件进行配置,以适用于多种服务提供商。
安装
通过Composer
$ composer require werk365/laraveloauthclient
使用
发布配置
$ php artisan vendor:publish --provider="Werk365\LaravelOAuthClient\LaravelOAuthClientServiceProvider"
使用提供的示例配置配置。
然后按以下方式使用该包:
use Werk365\LaravelOAuthClient\LaravelOAuthClient as OAuth; // ... $oauth = new OAuth("vendorname"); // Returns array defined in config $response = $oauth->getToken($code); //Returns array defined in config $response = $oauth->getInfo($accesstoken); //Returns array defined in config $response = $oauth->refreshToken($refreshtoken);
配置
提供的配置示例,编辑值以匹配供应商规范
<?php return [ 'vendor1' => [ 'client_id' => '1234', 'client_secret' => '12345', 'redirect_uri' => 'https://www.example.com/oauth2/vendor1', 'token' => [ 'url' => 'https://login.vendor.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.vendor.example.com/oauth2/token', 'method' => 'POST', 'grant_type' => 'authorization_code', 'fields' => "*", 'auth' => 'body', ], 'info' => [ 'url' => 'https://login.vendor.example.com/oauth2/metadata', 'method' => 'GET', 'fields' => [ 'metadata1', 'metadata2', ], ], ], 'vendor2' => ['...'], ];
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
$ composer test
安全
如果您发现任何与安全相关的问题,请通过电子邮件联系作者,而不是使用问题跟踪器。