chocofamilyme/oauth2-client
Composer 安装命令:
composer require chocofamilyme/oauth2-client
包简介
PHP OAuth2.0 client authentication library
关键字:
README 文档
README
OAuth 2.0 authentication client. It provides multiple grant types, using which you can get authentication data.
Installation
composer require chocofamilyme/oauth2-client
Usage
Grand type "password"
<?php use Chocofamilyme\OAuth2\Client\Authentication; use Chocofamilyme\OAuth2\Client\GrandTypes\PasswordGrandType; $grantType = new PasswordGrandType('client_id', 'username', 'password'); $oauth2 = new Authentication($grantType, 'http://oauth.server.com/auth/token'); $authData = $oauth2->getAuthData(); var_dump($authData);
Grand type "client_credentials"
<?php use Chocofamilyme\OAuth2\Client\Authentication; use Chocofamilyme\OAuth2\Client\GrandTypes\ClientCredentialsGrandType; $grantType = new ClientCredentialsGrandType('client_id', 'client_secret'); $oauth2 = new Authentication($grantType, 'http://oauth.server.com/auth/token'); $authData = $oauth2->getAuthData(); var_dump($authData);
Extending
- You can also extend this library with your grant types, see
GrantTypeInterface. - You can also use your own http client, it just has to implement
HttpClientInterface - If your OAuth 2.0 server gives the response not in the format this library can understand, just write your own response class which has to implement
ResponseInterface
Every custom module can then be used in the constructor of the Authentication class
new \Chocofamilyme\OAuth2\Client\Authentication(GrantTypeInterface $grantType, string $authTokenUrl, HttpClientInterface $httpClient = null, ResponseInterface $responseInterface = null)
统计信息
- 总下载量: 814
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-12-27