From 17b9e0bf99aa4d6d997dbe96bfa1584d2bbe78b4 Mon Sep 17 00:00:00 2001 From: rdvetromilla <44167963+rdvetromilla@users.noreply.github.com> Date: Thu, 11 Feb 2021 16:46:14 -0300 Subject: [PATCH] Fix: Appends Authorization Bearer Header for GET methods to avoid un-authorized issues (#2) --- src/Getnet/API/Request.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Getnet/API/Request.php b/src/Getnet/API/Request.php index d1a0d0b..b06c5ea 100644 --- a/src/Getnet/API/Request.php +++ b/src/Getnet/API/Request.php @@ -125,7 +125,8 @@ private function send(Getnet $credentials, $url_path, $method, $json = NULL) { $defaultCurlOptions[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $credentials->getAuthorizationToken(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); - + } elseif ($method == self::CURL_TYPE_GET) { + $defaultCurlOptions[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $credentials->getAuthorizationToken(); } elseif ($method == self::CURL_TYPE_PUT) { $defaultCurlOptions[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $credentials->getAuthorizationToken(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, self::CURL_TYPE_PUT); @@ -219,4 +220,4 @@ public function put(Getnet $credentials, $url_path, $params) { return $this->send($credentials, $url_path, self::CURL_TYPE_PUT, $params); } -} \ No newline at end of file +}