sarahman / oauth-tokens-client
This package handles the oauth tokens with caching functionality.
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: ~4.0
- illuminate/support: 4.*
- psr/simple-cache: ^1.0
This package is auto-updated.
Last update: 2025-06-14 05:49:48 UTC
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( 'tokenUrl' => null, 'refreshUrl' => null, 'clientId' => null, 'clientSecret' => null, ), );
- 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( 'tokenUrl' => 'http://localhost/grant-token', 'refreshUrl' => 'http://localhost/refresh-token', 'clientId' => 1, 'clientSecret' => '**********', ), ); $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.