Package Data | |
---|---|
Maintainer Username: | sarahman |
Maintainer Contact: | aabid048@gmail.com (Syed Abidur Rahman) |
Package Create Date: | 2025-06-09 |
Package Last Update: | 2025-07-08 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-07-09 03:00:03 |
Package Statistics | |
---|---|
Total Downloads: | 11 |
Monthly Downloads: | 11 |
Daily Downloads: | 9 |
Total Stars: | 0 |
Total Watchers: | 0 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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.
composer require sarahman/oauth-tokens-client
// 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.
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);
You might go to the project directory and run the following command to run test code.
composer test
Feel free to contribute in this library. Please make your changes and send us pull requests.
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.
The MIT License (MIT). Please see License File for more information.