PHPackages                             sarahman/oauth-tokens-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. sarahman/oauth-tokens-client

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

sarahman/oauth-tokens-client
============================

This package handles the oauth tokens with caching functionality.

1.1.1(7mo ago)02.4k↓47.6%MITPHPPHP &gt;=5.3.0

Since Jun 21Pushed 7mo agoCompare

[ Source](https://github.com/sarahman/oauth-tokens-client)[ Packagist](https://packagist.org/packages/sarahman/oauth-tokens-client)[ RSS](/packages/sarahman-oauth-tokens-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (10)Used By (0)

Oauth Tokens Client
===================

[](#oauth-tokens-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3430af5e0959ec1f9383c6a92a54d822f8b86012c56620346c4ab1e366c23a88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sarahman/oauth-tokens-client)[![Build Status](https://camo.githubusercontent.com/0fcdb1c03c1982eaafa395839eea6d66e9f992c4056e1c9dfacb2ce6434beb80/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/sarahman/oauth-tokens-client)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4ba73d4f0ab9f002eacd41d0fba52eb8e3dee13717a08615a9f6fd533c9ab14e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sarahman/oauth-tokens-client/?branch=master)[![StyleCI](https://camo.githubusercontent.com/1f80032b233eeacbaf97eb60990b616992f8cb2cf62614db4af91eccff283b72/68747470733a2f2f7374796c6563692e696f2f7265706f732f3939393137343633302f736869656c64)](https://styleci.io/repos/999174630)[![Total Downloads](https://camo.githubusercontent.com/f7834f40579a562f4ba287890432c9acae5fc3badaaf6b7187730d04de8da8c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sarahman/oauth-tokens-client)[![License](https://camo.githubusercontent.com/15f6cace01e8492089a85b3d07de374384aa297a16333c7ec3107fcc4e0bc85e/687474703a2f2f706f7365722e707567782e6f72672f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742f6c6963656e7365)](https://packagist.org/packages/sarahman/oauth-tokens-client)[![PHP Version Require](https://camo.githubusercontent.com/4dacb9e0d991655fd71a2f44ff87e6195216a1d5fe173785d337447aa79211f5/687474703a2f2f706f7365722e707567782e6f72672f73617261686d616e2f6f617574682d746f6b656e732d636c69656e742f726571756972652f706870)](https://packagist.org/packages/sarahman/oauth-tokens-client)

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
------------

[](#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,
    ,
    $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
-------

[](#testing)

You might go to the project directory and run the following command to run test code.

```
composer test
```

Contribution
------------

[](#contribution)

Feel free to contribute in this library. Please make your changes and send us [pull requests](https://github.com/sarahman/oauth-tokens-client/pulls).

Security Issues
---------------

[](#security-issues)

If you discover any security related issues, please feel free to create an issue in the [issue tracker](https://github.com/oauth-tokens-client/issues) or write us at .

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance63

Regular maintenance activity

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

6

Last Release

223d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c482155504a6d98bd167e89aaf9a873d1355cd771cbe2a0c11cab87a5296845?d=identicon)[sarahman](/maintainers/sarahman)

---

Top Contributors

[![sarahman](https://avatars.githubusercontent.com/u/3045127?v=4)](https://github.com/sarahman "sarahman (9 commits)")

---

Tags

clientlaraveltokenslibrarycacheoauthpassport

### Embed Badge

![Health badge](/badges/sarahman-oauth-tokens-client/health.svg)

```
[![Health](https://phpackages.com/badges/sarahman-oauth-tokens-client/health.svg)](https://phpackages.com/packages/sarahman-oauth-tokens-client)
```

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
