Skip to content

Commit

Permalink
Fix: Appends Authorization Bearer Header for GET methods to avoid un-…
Browse files Browse the repository at this point in the history
…authorized issues (#2)
  • Loading branch information
rdvetromilla authored Feb 11, 2021
1 parent 6c8e0f5 commit 17b9e0b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Getnet/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -219,4 +220,4 @@ public function put(Getnet $credentials, $url_path, $params) {
return $this->send($credentials, $url_path, self::CURL_TYPE_PUT, $params);
}

}
}

0 comments on commit 17b9e0b

Please sign in to comment.