PHPackages                             arm-yan/guzzle-oauth2 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. arm-yan/guzzle-oauth2

ActiveLibrary[HTTP &amp; Networking](/categories/http)

arm-yan/guzzle-oauth2
=====================

An OAuth2 plugin (subscriber) for Guzzle

2.2.0(5y ago)045MITPHP

Since May 20Pushed 5y agoCompare

[ Source](https://github.com/arm-yan/guzzle-oauth2)[ Packagist](https://packagist.org/packages/arm-yan/guzzle-oauth2)[ RSS](/packages/arm-yan-guzzle-oauth2/feed)WikiDiscussions developer Synced today

READMEChangelog (1)Dependencies (3)Versions (12)Used By (0)

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

[](#guzzle-oauth2)

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:

```
        "arm-yan/guzzle-oauth2": "~2.0"
```

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

```
        "arm-yan/guzzle-oauth2": "~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 ArmYan\Guzzle\Oauth2\GrantType\RefreshToken;
use ArmYan\Guzzle\Oauth2\GrantType\PasswordCredentials;
use ArmYan\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

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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 ~258 days

Recently: every ~504 days

Total

10

Last Release

2101d ago

Major Versions

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd2ee3aab22f87ef5199686e7348a06025a61fead5009abdbd191cd5eb6c52c7?d=identicon)[armyan](/maintainers/armyan)

---

Top Contributors

[![arm-yan](https://avatars.githubusercontent.com/u/18047143?v=4)](https://github.com/arm-yan "arm-yan (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arm-yan-guzzle-oauth2/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M885](/packages/laravel-socialite)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.7M18](/packages/xeroapi-xero-php-oauth2)[civicrm/civicrm-core

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

751291.4k43](/packages/civicrm-civicrm-core)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)

PHPackages © 2026

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