From 189a689717bc886d68229bc54016b238cdb6486f Mon Sep 17 00:00:00 2001 From: Prefinem Date: Wed, 25 Jun 2014 16:04:52 -0500 Subject: [PATCH 1/2] Fix Issue #1 https://github.com/Adyg/php-imgur-api-client/issues/1 --- lib/Imgur/Auth/OAuth2.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Imgur/Auth/OAuth2.php b/lib/Imgur/Auth/OAuth2.php index e671ec1..4fc914a 100644 --- a/lib/Imgur/Auth/OAuth2.php +++ b/lib/Imgur/Auth/OAuth2.php @@ -3,6 +3,7 @@ namespace Imgur\Auth; use Imgur\Listener; +use Imgur\Exception\AuthException; /** * Authentication class used for handling OAuth2 @@ -196,4 +197,4 @@ public function sign($httpClient) { public function addListener($httpClient, $eventName, $listener) { $httpClient->addListener($eventName, $listener); } -} \ No newline at end of file +} From eea8131e3fd2c8230d3b7f76256da9823892a68b Mon Sep 17 00:00:00 2001 From: Prefinem Date: Tue, 8 Jul 2014 21:45:17 -0500 Subject: [PATCH 2/2] Fix OAuth set AccessToken the token sometimes comes back in the form $token['data']['access_token'] so we need to check if it is there and use that instead. --- lib/Imgur/Auth/OAuth2.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Imgur/Auth/OAuth2.php b/lib/Imgur/Auth/OAuth2.php index 4fc914a..8fe1bc4 100644 --- a/lib/Imgur/Auth/OAuth2.php +++ b/lib/Imgur/Auth/OAuth2.php @@ -144,6 +144,11 @@ public function setAccessToken($token, $httpClient) { throw new AuthException('Token is not a valid json string.'); } + if ( isset($token['data']['access_token'])) { + $token = $token['data']; + } + + if (! isset($token['access_token'])) { throw new AuthException('Access token could not be retrieved from the decoded json response.'); }