From 97e0a56b6504482a5c8913da502fd50b700d823f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 25 Jun 2019 18:08:21 -0300 Subject: [PATCH] Updating oauth.php file to match the new base api --- src/{oauth.php => Oauth.php} | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) rename src/{oauth.php => Oauth.php} (87%) diff --git a/src/oauth.php b/src/Oauth.php similarity index 87% rename from src/oauth.php rename to src/Oauth.php index 37f0b78..8ac58ee 100644 --- a/src/oauth.php +++ b/src/Oauth.php @@ -1,23 +1,24 @@ * @link https://github.com/brunofontes */ + namespace BrunoFontes\Memsource; -class Oauth extends \BrunoFontes\Memsource +class Oauth extends \BrunoFontes\Memsource\FetchApi { private $_url = '/oauth'; - + /** * Get the URL to generate the Authorization Code from Memsource * * @param string $client_id Memsource client ID * @param string $client_secret Memsource client secret * @param string $callback_uri URL that Memsource will redirect to - * + * * @return string the authorization code */ public function getAuthorizationCodeUrl(string $client_id, string $callback_uri) @@ -37,10 +38,7 @@ class Oauth extends \BrunoFontes\Memsource CURLOPT_POST => true, CURLOPT_POSTFIELDS => $content ]; - $response = $this->curl($token_url, $params); - if ($respose['error']) { - throw new Exception("Error getting access token", 1); - } + $response = json_decode($this->curl($token_url, $params), true); return $response['access_token']; } }