2017 © Pedro Peláez
 

library guzzle-bundle-oauth2-plugin

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

image

gregurco/guzzle-bundle-oauth2-plugin

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

  • Monday, July 2, 2018
  • by gregurco
  • Repository
  • 2 Watchers
  • 6 Stars
  • 3,325 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 9 Versions
  • 44 % Grown

The README.md

Guzzle Bundle OAuth2 Plugin

Build Status Coverage Status SensioLabsInsight, (*1)

This plugin integrates OAuth2 functionality into Guzzle Bundle, a bundle for building RESTful web service clients., (*2)


Prerequisites

Installation

To install this bundle, run the command below on the command line and you will get the latest stable version from Packagist., (*3)

``` bash composer require gregurco/guzzle-bundle-oauth2-plugin, (*4)


## Usage ### Enable bundle Find next lines in `src/Kernel.php`: ```php foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); } }

and replace them by:, (*5)

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

With default grant type (client)

``` yaml, (*6)

app/config/config.yml

eight_points_guzzle: clients: api_payment: base_url: "http://api.domain.tld", (*7)

        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 ``` yaml # 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

``` yaml, (*8)

app/config/config.yml

eight_points_guzzle: clients: api_payment: base_url: "http://api.domain.tld", (*9)

        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"

```, (*10)

Options

Key Description Required Example
base_uri URL of oAuth2 server. yes https://example.com
token_url The path that will be concatenated with base_uri. br/Default: /oauth2/token no /oauth/token
client_id The client identifier issued to the client during the registration process yes s6BhdRkqt3
client_secret The client secret no 7Fjfp0ZBr1KtDRbnfVdmIw
username The resource owner username for PasswordCredentials grant type johndoe
password The resource owner password for PasswordCredentials grant type A3ddj3w
auth_location The place where to put client_id and client_secret in auth request. br/Default: headers. Allowed values: body, headers. no body
resource The App ID URI of the web API (secured resource) no https://service.contoso.com/
private_key Path to private key for JwtBearer grant type "%kernel.root_dir%/path/to/private.key"
scope One or more scope values indicating which parts of the user's account you wish to access no administration
audience no
grant_type Grant type class path. Class should implement GrantTypeInterface. br/ Default: Sainsburys\\Guzzle\\Oauth2\\GrantType\\ClientCredentials no Sainsburys\\Guzzle\\Oauth2\\GrantType\\PasswordCredentialsbr/Sainsburys\\Guzzle\\Oauth2\\GrantType\\AuthorizationCodebr/Sainsburys\\Guzzle\\Oauth2\\GrantType\\JwtBearer
persistent Token will be stored in session unless grant_type is client credentials; in which case it will be stored in the app cache. br/ Default: false no
retry_limit How many times request will be repeated on failure. br/ Default: 5 no

See more information about middleware here., (*11)

License

This middleware is licensed under the MIT License - see the LICENSE file for details, (*12)

The Versions

02/07 2018

dev-master

9999999-dev https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

02/07 2018

v1.0.5

1.0.5.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

09/05 2018

dev-doc_for_sf4

dev-doc_for_sf4 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

17/04 2018

v1.0.4

1.0.4.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

17/04 2018

dev-persistent_storage

dev-persistent_storage https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

09/11 2017

v1.0.3

1.0.3.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

07/11 2017

v1.0.2

1.0.2.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

07/11 2017

v1.0.1

1.0.1.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client

04/11 2017

v1.0.0

1.0.0.0 https://github.com/gregurco/GuzzleBundleOAuth2Plugin

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

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework rest http client oauth2 web service http client