From 41638da086b9955bcf6caf71ccc5b4b924fd5267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gon=C3=A7alves?= Date: Tue, 13 Dec 2016 18:20:09 +0000 Subject: [PATCH] Fix handling of user authorize response This fixes the handling of the user authorize response by retrieving the access token from the array that is given by the authorize endpoint. --- lib/Uphold/UpholdClient.php | 5 ++++- test/Uphold/Tests/Unit/UpholdClientTest.php | 2 +- travis.php.ini | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Uphold/UpholdClient.php b/lib/Uphold/UpholdClient.php index cae735c..fe24225 100644 --- a/lib/Uphold/UpholdClient.php +++ b/lib/Uphold/UpholdClient.php @@ -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); } /** diff --git a/test/Uphold/Tests/Unit/UpholdClientTest.php b/test/Uphold/Tests/Unit/UpholdClientTest.php index 2f897ae..578b660 100644 --- a/test/Uphold/Tests/Unit/UpholdClientTest.php +++ b/test/Uphold/Tests/Unit/UpholdClientTest.php @@ -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(); diff --git a/travis.php.ini b/travis.php.ini index 92a5ffd..8a15b62 100644 --- a/travis.php.ini +++ b/travis.php.ini @@ -1 +1 @@ -memory_limit = 2048M +memory_limit = 4096M