2017 © Pedro Peláez
 

library guzzle-oauth2-plugin

An OAuth2 plugin (subscriber) for Guzzle

image

commerceguys/guzzle-oauth2-plugin

An OAuth2 plugin (subscriber) for Guzzle

  • Sunday, December 13, 2015
  • by bojanz
  • Repository
  • 15 Watchers
  • 119 Stars
  • 649,586 Installations
  • PHP
  • 29 Dependents
  • 0 Suggesters
  • 60 Forks
  • 9 Open issues
  • 10 Versions
  • 6 % Grown

The README.md

guzzle-oauth2-plugin

Provides an OAuth2 plugin (subscriber) for Guzzle., (*1)

Build Status Code Coverage, (*2)

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

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

Guzzle 3 compatibility continues in the 1.0 branch:, (*4)

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

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

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

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.

The Versions

13/12 2015

dev-master

9999999-dev

An OAuth2 plugin (subscriber) for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

13/12 2015

v2.1.1

2.1.1.0

An OAuth2 plugin (subscriber) for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

27/05 2015

v2.1.0

2.1.0.0

An OAuth2 plugin (subscriber) for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

05/05 2015

v2.0.2

2.0.2.0

An OAuth2 plugin (subscriber) for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

26/03 2015

v2.0.1

2.0.1.0

An OAuth2 plugin (subscriber) for Guzzle 5.x

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

19/03 2015

v2.0.0

2.0.0.0

An OAuth2 plugin (subscriber) for Guzzle 5.x

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

19/03 2015

v2.0.0-beta2

2.0.0.0-beta2

An OAuth2 plugin (subscriber) for Guzzle 5.x

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bojan Zivanovic
by Damien Tournoud

23/02 2015

v2.0.0-beta1

2.0.0.0-beta1

An OAuth2 plugin for Guzzle 5.x

  Sources   Download

MIT

The Requires

 

by Bojan Zivanovic
by Damien Tournoud

20/05 2014

1.0.x-dev

1.0.9999999.9999999-dev

An OAuth2 plugin for guzzle

  Sources   Download

MIT

The Requires

 

by Bojan Zivanovic
by Damien Tournoud

20/05 2014

v1.0.0

1.0.0.0

An OAuth2 plugin for guzzle

  Sources   Download

MIT

The Requires

 

by Bojan Zivanovic
by Damien Tournoud