sarahman/oauth-tokens-client
最新稳定版本:1.1.1
Composer 安装命令:
composer require sarahman/oauth-tokens-client
包简介
This package handles the oauth tokens with caching functionality.
README 文档
README
PHP library built by PSR-16 simple cache interface can be used in any php project or it has laravel support to install through its service provider.
Installation
- Step 1: You can install the package via composer:
composer require sarahman/oauth-tokens-client
- Step 2.a: Next, for the laravel projects, we can load its service provider:
// app/config/app.php 'providers' => [ ... 'Sarahman\OauthTokensClient\OauthTokensClientServiceProvider', ];
You can publish the config file with:
php artisan config:publish sarahman/oauth-tokens-client
This is the contents of the published config file:
return array( 'TOKEN_PREFIXES' => array( 'ACCESS' => 'oauth_access_token', 'REFRESH' => 'oauth_refresh_token', ), 'LOCK_KEY' => 'oauth_token_refresh_lock', 'OAUTH_CREDENTIAL' => array( 'GRANT_TYPE' => 'client_credentials', 'TOKEN_URL' => null, 'REFRESH_URL' => null, 'CLIENT_ID' => null, 'CLIENT_SECRET' => null, 'USERNAME' => null, 'PASSWORD' => null, 'SCOPE' => '', ), );
Note: If we use password grant, then we must set USERNAME and PASSWORD config keys.
- Step 2.b: for the regular php projects, we might directly add these following codes:
require "vendor/autoload.php"; $clientConfig = array( 'TOKEN_PREFIXES' => array( 'ACCESS' => 'oauth_access_token', 'REFRESH' => 'oauth_refresh_token', ), 'LOCK_KEY' => 'oauth_token_refresh_lock', 'OAUTH_CREDENTIAL' => array( 'GRANT_TYPE' => 'client_credentials', 'TOKEN_URL' => 'http://localhost/grant-token', 'REFRESH_URL' => 'http://localhost/refresh-token', 'CLIENT_ID' => 1, 'CLIENT_SECRET' => '**********', 'SCOPE' => '', ), ); $client = new OAuthClient( new Client, <CACHE_STORE>, $clientConfig['OAUTH_CREDENTIAL'], $clientConfig['TOKEN_PREFIXES'], $clientConfig['LOCK_KEY'] ); // Set Cache key. $data = array( 'sample' => 'data', 'another' => 'data', ); $response = $client->request('POST', 'http://localhost/get-user', $data); var_dump($response);
Testing
You might go to the project directory and run the following command to run test code.
composer test
Contribution
Feel free to contribute in this library. Please make your changes and send us pull requests.
Security Issues
If you discover any security related issues, please feel free to create an issue in the issue tracker or write us at aabid048@gmail.com.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-11