Skip to content

Commit

Permalink
Fix handling of user authorize response
Browse files Browse the repository at this point in the history
This fixes the handling of the user authorize response by retrieving
the access token from the array that is given by the authorize endpoint.
  • Loading branch information
joaonice committed Dec 14, 2016
1 parent 2626bf3 commit 234279f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/Uphold/UpholdClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ public function authorizeUser($code)
array_merge($this->getDefaultHeaders(), $headers)
);

return $this->getUser($response->getContent());
$content = $response->getContent();
$bearerToken = isset($content['access_token']) ? $content['access_token'] : null;

return $this->getUser($bearerToken);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Uphold/Tests/Unit/UpholdClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function shouldReturnAuthorizedUserWhenResponseReturnsBearerToken()
'grant_type' => 'authorization_code',
));

$response = $this->getResponseMock('xyzzy');
$response = $this->getResponseMock(array('access_token' => 'xyzzy'));

$httpClient = $this->getHttpClientMock();

Expand Down

0 comments on commit 234279f

Please sign in to comment.