PHPackages                             rampmaster/guzzle-oauth2-plugin - 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. rampmaster/guzzle-oauth2-plugin

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

rampmaster/guzzle-oauth2-plugin
===============================

An OAuth2 plugin (subscriber) for Guzzle

v2.1.2(10y ago)015MITPHP

Since May 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/rampmaster/guzzle-oauth2-plugin)[ Packagist](https://packagist.org/packages/rampmaster/guzzle-oauth2-plugin)[ RSS](/packages/rampmaster-guzzle-oauth2-plugin/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (11)Used By (0)

guzzle-oauth2-plugin
====================

[](#guzzle-oauth2-plugin)

Provides an OAuth2 plugin (subscriber) for [Guzzle](http://guzzlephp.org/).

[![Build Status](https://camo.githubusercontent.com/b36ee25ccc67069204801055098762a6c57de4b0c3501efcd8964466a031f326/68747470733a2f2f7472617669732d63692e6f72672f636f6d6d65726365677579732f67757a7a6c652d6f61757468322d706c7567696e2e737667)](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin)[![Code Coverage](https://camo.githubusercontent.com/f7c72721b50a3174a373949b334874180689d0bd4c8bdd601b7122dfb93fa598/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6d6d65726365677579732f67757a7a6c652d6f61757468322d706c7567696e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/commerceguys/guzzle-oauth2-plugin/?branch=master)

Version 2.x (on the `master` branch) is intended for Guzzle 5:

```
        "commerceguys/guzzle-oauth2-plugin": "~2.0"
```

Guzzle 3 compatibility continues in the [`1.0`](https://github.com/commerceguys/guzzle-oauth2-plugin/tree/1.0) branch:

```
        "commerceguys/guzzle-oauth2-plugin": "~1.0"
```

Features
--------

[](#features)

- Acquires access tokens via one of the supported grant types (code, client credentials, user credentials, refresh token). Or you can set an access token yourself.
- Supports refresh tokens (stores them and uses them to get new access tokens).
- Handles token expiration (acquires new tokens and retries failed requests).

Running the tests
-----------------

[](#running-the-tests)

First make sure you have all the dependencies in place by running `composer install --prefer-dist`, then simply run `./bin/phpunit`.

Example
-------

[](#example)

```
use GuzzleHttp\Client;
use CommerceGuys\Guzzle\Oauth2\GrantType\RefreshToken;
use CommerceGuys\Guzzle\Oauth2\GrantType\PasswordCredentials;
use CommerceGuys\Guzzle\Oauth2\Oauth2Subscriber;

$base_url = 'https://example.com';

$oauth2Client = new Client(['base_url' => $base_url]);

$config = [
    'username' => 'test@example.com',
    'password' => 'test password',
    'client_id' => 'test-client',
    'scope' => 'administration',
];

$token = new PasswordCredentials($oauth2Client, $config);
$refreshToken = new RefreshToken($oauth2Client, $config);

$oauth2 = new Oauth2Subscriber($token, $refreshToken);

$client = new Client([
    'defaults' => [
        'auth' => 'oauth2',
        'subscribers' => [$oauth2],
    ],
]);

$response = $client->get('https://example.com/api/user/me');

print_r($response->json());

// Use $oauth2->getAccessToken(); and $oauth2->getRefreshToken() to get tokens
// that can be persisted for subsequent requests.
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~81 days

Recently: every ~104 days

Total

10

Last Release

3696d ago

Major Versions

v1.0.0 → v2.0.0-beta12015-02-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/978024?v=4)[Roberto Moreno](/maintainers/rampmaster)[@rampmaster](https://github.com/rampmaster)

---

Top Contributors

[![pjcdawkins](https://avatars.githubusercontent.com/u/1465106?v=4)](https://github.com/pjcdawkins "pjcdawkins (26 commits)")[![bojanz](https://avatars.githubusercontent.com/u/330162?v=4)](https://github.com/bojanz "bojanz (9 commits)")[![omissis](https://avatars.githubusercontent.com/u/197604?v=4)](https://github.com/omissis "omissis (8 commits)")[![steffkes](https://avatars.githubusercontent.com/u/325361?v=4)](https://github.com/steffkes "steffkes (5 commits)")[![fullpipe](https://avatars.githubusercontent.com/u/929659?v=4)](https://github.com/fullpipe "fullpipe (2 commits)")[![marfillaster](https://avatars.githubusercontent.com/u/121793?v=4)](https://github.com/marfillaster "marfillaster (1 commits)")[![rampmaster](https://avatars.githubusercontent.com/u/978024?v=4)](https://github.com/rampmaster "rampmaster (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rampmaster-guzzle-oauth2-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/rampmaster-guzzle-oauth2-plugin/health.svg)](https://phpackages.com/packages/rampmaster-guzzle-oauth2-plugin)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k34](/packages/neuron-core-neuron-ai)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[forumify/forumify-platform

122.0k12](/packages/forumify-forumify-platform)

PHPackages © 2026

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