From d8c0ab0da3939d2da38bdbfb4ef8efa9b7e45c76 Mon Sep 17 00:00:00 2001 From: Robert Baelde Date: Sun, 5 Feb 2017 11:24:49 +0100 Subject: [PATCH 1/2] See https://github.com/mollie/laravel-mollie/issues/22 --- src/MollieConnectProvider.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/MollieConnectProvider.php b/src/MollieConnectProvider.php index c9f3c2f..d011853 100644 --- a/src/MollieConnectProvider.php +++ b/src/MollieConnectProvider.php @@ -107,6 +107,40 @@ public function getAccessToken($code) return $this->parseAccessToken($response->getBody()); } + /** + * Get the access token with a refresh token. + * + * @param string $code + * + * @return array + */ + public function getRefreshTokenResponse($code) + { + $response = $this->getHttpClient()->post($this->getTokenUrl(), [ + 'headers' => ['Accept' => 'application/json'], + 'form_params' => $this->getRefreshTokenFields($code), + ]); + return json_decode($response->getBody(), true); + } + /** + * Get the refresh tokenfields with a refresh token. + * + * @param string $code + * + * @return array + */ + protected function getRefreshTokenFields($code) + { + + return [ + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, + 'code' => $code, + 'grant_type' => 'refresh_token', + 'refresh_token' => $code, + ]; + } + /** * Get the POST fields for the token request. * From ad7397b6e11ea00802d831a284a2dd57faf9a190 Mon Sep 17 00:00:00 2001 From: Robert Baelde Date: Thu, 16 Mar 2017 16:59:12 +0100 Subject: [PATCH 2/2] Updated the code variable name, and removed code paramater --- src/MollieConnectProvider.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/MollieConnectProvider.php b/src/MollieConnectProvider.php index d011853..8b77169 100644 --- a/src/MollieConnectProvider.php +++ b/src/MollieConnectProvider.php @@ -110,34 +110,33 @@ public function getAccessToken($code) /** * Get the access token with a refresh token. * - * @param string $code + * @param string $refresh_token * * @return array */ - public function getRefreshTokenResponse($code) + public function getRefreshTokenResponse($refresh_token) { $response = $this->getHttpClient()->post($this->getTokenUrl(), [ 'headers' => ['Accept' => 'application/json'], - 'form_params' => $this->getRefreshTokenFields($code), + 'form_params' => $this->getRefreshTokenFields($refresh_token), ]); return json_decode($response->getBody(), true); } /** * Get the refresh tokenfields with a refresh token. * - * @param string $code + * @param string $refresh_token * * @return array */ - protected function getRefreshTokenFields($code) + protected function getRefreshTokenFields($refresh_token) { return [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, - 'code' => $code, 'grant_type' => 'refresh_token', - 'refresh_token' => $code, + 'refresh_token' => $refresh_token, ]; }