Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/Imgur/Auth/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Imgur\Auth;

use Imgur\Listener;
use Imgur\Exception\AuthException;

/**
* Authentication class used for handling OAuth2
Expand Down Expand Up @@ -143,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.');
}
Expand Down Expand Up @@ -196,4 +202,4 @@ public function sign($httpClient) {
public function addListener($httpClient, $eventName, $listener) {
$httpClient->addListener($eventName, $listener);
}
}
}