PHPackages                             gregurco/guzzle-bundle-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. [Framework](/categories/framework)
4. /
5. gregurco/guzzle-bundle-oauth2-plugin

ActiveLibrary[Framework](/categories/framework)

gregurco/guzzle-bundle-oauth2-plugin
====================================

OAuth2 Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

v2.3.0(2y ago)13348.3k↓25.9%13[4 issues](https://github.com/gregurco/GuzzleBundleOAuth2Plugin/issues)MITPHPPHP &gt;=7.2

Since Nov 3Pushed 2y ago2 watchersCompare

[ Source](https://github.com/gregurco/GuzzleBundleOAuth2Plugin)[ Packagist](https://packagist.org/packages/gregurco/guzzle-bundle-oauth2-plugin)[ Docs](https://github.com/gregurco/GuzzleBundleOAuth2Plugin)[ RSS](/packages/gregurco-guzzle-bundle-oauth2-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (14)Used By (0)

Guzzle Bundle OAuth2 Plugin
===========================

[](#guzzle-bundle-oauth2-plugin)

[![Build Status](https://camo.githubusercontent.com/df4717b6bbd2192d916cfa5e358ea249a3136cd45596acc4ac90c6e43b8766e8/68747470733a2f2f7472617669732d63692e6f72672f677265677572636f2f47757a7a6c6542756e646c654f4175746832506c7567696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gregurco/GuzzleBundleOAuth2Plugin)[![Coverage Status](https://camo.githubusercontent.com/755a761e253ae6a4e40265cd4495720117c8c2eaca62a1d558c8f4b3df8db6b1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f677265677572636f2f47757a7a6c6542756e646c654f4175746832506c7567696e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/gregurco/GuzzleBundleOAuth2Plugin)[![SensioLabsInsight](https://camo.githubusercontent.com/ce125fbd358a580a269d01d11fc4924a3e3dd8faa2a275bd1c82ecb9a6ecac77/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65626134663265362d326332612d346539322d383562362d6333326162336163336161372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/eba4f2e6-2c2a-4e92-85b6-c32ab3ac3aa7)

This plugin integrates [OAuth2](http://www.xml.com/pub/a/2003/12/17/dive.html) functionality into [Guzzle Bundle](https://github.com/8p/EightPointsGuzzleBundle), a bundle for building RESTful web service clients.

---

Prerequisites
-------------

[](#prerequisites)

- PHP 7.2 or above
- [Guzzle Bundle](https://github.com/8p/EightPointsGuzzleBundle)
- [guzzle-oauth2-plugin](https://github.com/Sainsburys/guzzle-oauth2-plugin)

Installation
------------

[](#installation)

To install this bundle, run the command below on the command line and you will get the latest stable version from [Packagist](https://packagist.org/packages/gregurco/guzzle-bundle-oauth2-plugin).

```
composer require gregurco/guzzle-bundle-oauth2-plugin
```

Usage
-----

[](#usage)

### Enable bundle

[](#enable-bundle)

Find next lines in `src/Kernel.php`:

```
foreach ($contents as $class => $envs) {
    if (isset($envs['all']) || isset($envs[$this->environment])) {
        yield new $class();
    }
}
```

and replace them by:

```
foreach ($contents as $class => $envs) {
    if (isset($envs['all']) || isset($envs[$this->environment])) {
        if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) {
            yield new $class([
                new \Gregurco\Bundle\GuzzleBundleOAuth2Plugin\GuzzleBundleOAuth2Plugin(),
            ]);
        } else {
            yield new $class();
        }
    }
}
```

### Basic configuration

[](#basic-configuration)

#### With default grant type (client)

[](#with-default-grant-type-client)

```
# app/config/config.yml

eight_points_guzzle:
    clients:
        api_payment:
            base_url: "http://api.domain.tld"

            options:
                auth: oauth2

            # plugin settings
            plugin:
                oauth2:
                    base_uri:       "https://example.com"
                    token_url:      "/oauth/token"
                    client_id:      "test-client-id"
                    client_secret:  "test-client-secret" # optional
                    scope:          "administration"
```

#### With password grant type

[](#with-password-grant-type)

```
# app/config/config.yml

eight_points_guzzle:
    clients:
        api_payment:
            base_url: "http://api.domain.tld"

            options:
                auth: oauth2

            # plugin settings
            plugin:
                oauth2:
                    base_uri:       "https://example.com"
                    token_url:      "/oauth/token"
                    client_id:      "test-client-id"
                    username:       "johndoe"
                    password:       "A3ddj3w"
                    scope:          "administration"
                    grant_type:     "Sainsburys\\Guzzle\\Oauth2\\GrantType\\PasswordCredentials"
```

#### With client credentials in body

[](#with-client-credentials-in-body)

```
# app/config/config.yml

eight_points_guzzle:
    clients:
        api_payment:
            base_url: "http://api.domain.tld"

            options:
                auth: oauth2

            # plugin settings
            plugin:
                oauth2:
                    base_uri:       "https://example.com"
                    token_url:      "/oauth/token"
                    client_id:      "test-client-id"
                    scope:          "administration"
                    auth_location:  "body"
```

### Options

[](#options)

KeyDescriptionRequiredExamplebase\_uriURL of oAuth2 server.yestoken\_urlThe path that will be concatenated with base\_uri.
Default: `/oauth2/token`no/oauth/tokenclient\_idThe client identifier issued to the client during the registration processyess6BhdRkqt3client\_secretThe client secretno7Fjfp0ZBr1KtDRbnfVdmIwusernameThe resource owner usernamefor PasswordCredentials grant typejohndoepasswordThe resource owner passwordfor PasswordCredentials grant typeA3ddj3wauth\_locationThe place where to put client\_id and client\_secret in auth request.
Default: headers. Allowed values: body, headers.nobodyresourceThe App ID URI of the web API (secured resource)noprivate\_keyPath to private keyfor JwtBearer grant type`"%kernel.root_dir%/path/to/private.key"`scopeOne or more scope values indicating which parts of the user's account you wish to accessnoadministrationaudiencenogrant\_typeGrant type class path. Class should implement GrantTypeInterface.
 Default: `Sainsburys\\Guzzle\\Oauth2\\GrantType\\ClientCredentials`no`Sainsburys\\Guzzle\\Oauth2\\GrantType\\PasswordCredentials`
`Sainsburys\\Guzzle\\Oauth2\\GrantType\\AuthorizationCode`
`Sainsburys\\Guzzle\\Oauth2\\GrantType\\JwtBearer`persistentToken will be stored in session unless grant\_type is client credentials; in which case it will be stored in the app cache.
 Default: falsenoretry\_limitHow many times request will be repeated on failure.
 Default: 5noSee more information about middleware [here](https://github.com/Sainsburys/guzzle-oauth2-plugin).

License
-------

[](#license)

This middleware is licensed under the MIT License - see the LICENSE file for details

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 87.3% 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 ~195 days

Recently: every ~472 days

Total

13

Last Release

771d ago

Major Versions

v1.0.8 → v2.0.02020-02-28

PHP version history (4 changes)v1.0.0PHP ^7.0

v2.0.0PHP &gt;=7.1

v2.1.0PHP ^7.1|^8.0

v2.3.0PHP &gt;=7.2

### Community

Maintainers

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

---

Top Contributors

[![gregurco](https://avatars.githubusercontent.com/u/4052904?v=4)](https://github.com/gregurco "gregurco (55 commits)")[![Neirda24](https://avatars.githubusercontent.com/u/7036794?v=4)](https://github.com/Neirda24 "Neirda24 (5 commits)")[![chrisivens](https://avatars.githubusercontent.com/u/401928?v=4)](https://github.com/chrisivens "chrisivens (1 commits)")[![EugenGanshorn](https://avatars.githubusercontent.com/u/8372121?v=4)](https://github.com/EugenGanshorn "EugenGanshorn (1 commits)")[![moux2003](https://avatars.githubusercontent.com/u/4438388?v=4)](https://github.com/moux2003 "moux2003 (1 commits)")

---

Tags

bundleguzzleoauth2oauth2-middlewarephpsymfonysymfony-bundlehttpmiddlewarepluginclientframeworkrestcurlhttp clientweb serviceoauth2

### Embed Badge

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

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

###  Alternatives

[gregurco/guzzle-bundle-cache-plugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

11372.1k1](/packages/gregurco-guzzle-bundle-cache-plugin)[eightpoints/guzzle-wsse-middleware

WSSE Middleware for Guzzle, a PHP HTTP client library and framework for building RESTful web service clients

312.1M5](/packages/eightpoints-guzzle-wsse-middleware)

PHPackages © 2026

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