Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Mar 19, 2015
1 parent 3793cd9 commit 29a7cdb
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ install:
- composer install

script:
- ./vendor/bin/phpunit -c ./phpunit.xml --coverage-text
- ./vendor/bin/phpunit -c ./phpunit.xml --coverage-text
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
guzzle-oauth2-plugin
====================

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

[![Build Status](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin.svg)](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin)

The `master` branch is intended for Guzzle 5:
Version 2.x (on the `master` branch) is intended for Guzzle 5:
```json
"commerceguys/guzzle-oauth2-plugin": "dev-master"
"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:
Expand Down Expand Up @@ -52,12 +52,11 @@ $client = new Client([
],
]);

/** @var \GuzzleHttp\Message\Response */
$response = $client->get('https://example.com/api/user/me');

print_r($response->json());

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

```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commerceguys/guzzle-oauth2-plugin",
"description": "An OAuth2 plugin for Guzzle 5.x",
"description": "An OAuth2 plugin (subscriber) for Guzzle 5.x",
"license": "MIT",
"require": {
"guzzlehttp/guzzle": "~5.0"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class AccessToken

/**
* @param string $token
* @param string $type The token type (from OAuth2 key 'token_type').
* @param array $data Other token data.
* @param string $type The token type (from OAuth2 key 'token_type').
* @param array $data Other token data.
*/
public function __construct($token, $type, array $data = [])
{
Expand Down
1 change: 1 addition & 0 deletions src/GrantType/AuthorizationCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* Authorization code grant type.
*
* @link http://tools.ietf.org/html/rfc6749#section-4.1
*/
class AuthorizationCode extends GrantTypeBase
Expand Down
1 change: 1 addition & 0 deletions src/GrantType/ClientCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* Client credentials grant type.
*
* @link http://tools.ietf.org/html/rfc6749#section-4.4
*/
class ClientCredentials extends GrantTypeBase
Expand Down
2 changes: 1 addition & 1 deletion src/GrantType/GrantTypeBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace CommerceGuys\Guzzle\Oauth2\GrantType;

use CommerceGuys\Guzzle\Oauth2\AccessToken;
use GuzzleHttp\Collection;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Collection;

abstract class GrantTypeBase implements GrantTypeInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/GrantType/PasswordCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* Resource owner password credentials grant type.
*
* @link http://tools.ietf.org/html/rfc6749#section-4.3
*/
class PasswordCredentials extends GrantTypeBase
Expand Down
1 change: 1 addition & 0 deletions src/GrantType/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* Refresh token grant type.
*
* @link http://tools.ietf.org/html/rfc6749#section-6
*/
class RefreshToken extends GrantTypeBase implements RefreshTokenGrantTypeInterface
Expand Down
10 changes: 5 additions & 5 deletions src/Oauth2Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Oauth2Subscriber implements SubscriberInterface
/**
* Create a new Oauth2 subscriber.
*
* @param GrantTypeInterface $grantType
* @param GrantTypeInterface $grantType
* @param RefreshTokenGrantTypeInterface $refreshTokenGrantType
*/
public function __construct(GrantTypeInterface $grantType = null, RefreshTokenGrantTypeInterface $refreshTokenGrantType = null)
Expand All @@ -40,8 +40,8 @@ public function __construct(GrantTypeInterface $grantType = null, RefreshTokenGr
public function getEvents()
{
return [
'before' => ['onBefore', RequestEvents::SIGN_REQUEST],
'error' => ['onError', RequestEvents::EARLY],
'before' => ['onBefore', RequestEvents::SIGN_REQUEST],
'error' => ['onError', RequestEvents::EARLY],
];
}

Expand Down Expand Up @@ -141,8 +141,8 @@ public function getRefreshToken()
* Set the access token.
*
* @param AccessToken|string $accessToken
* @param string $type
* @param int $expires
* @param string $type
* @param int $expires
*/
public function setAccessToken($accessToken, $type = null, $expires = null)
{
Expand Down
6 changes: 2 additions & 4 deletions tests/MockOAuth2Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ protected function getResult(array $request)
{
if ($request['uri'] === $this->options['tokenPath']) {
$response = $this->oauth2Token($request);
}
elseif (strpos($request['uri'], 'api/') !== false) {
} elseif (strpos($request['uri'], 'api/') !== false) {
$response = $this->mockApiCall($request);
}
if (!isset($response)) {
Expand Down Expand Up @@ -85,8 +84,7 @@ protected function validTokenResponse()

if (isset($this->options['tokenExpires'])) {
$token['expires'] = $this->options['tokenExpires'];
}
elseif (isset($this->options['tokenExpiresIn'])) {
} elseif (isset($this->options['tokenExpiresIn'])) {
$token['expires_in'] = $this->options['tokenExpiresIn'];
}

Expand Down
4 changes: 2 additions & 2 deletions tests/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function getClient(array $options = [], array $serverOptions = [])
{
$server = new MockOAuth2Server($serverOptions);
return new Client([
'handler' => $server->getHandler()
] + $options);
'handler' => $server->getHandler()
] + $options);
}
}

0 comments on commit 29a7cdb

Please sign in to comment.