Skip to content

Commit 7932f49

Browse files
committed
Fixed OAuth curl error: HTTP version
1 parent 8455bf7 commit 7932f49

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/includes/Curl.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class Curl implements GatewayInterface
4444
public const MAXREDIRS = CURLOPT_MAXREDIRS;
4545
public const ENCODING = CURLOPT_ENCODING;
4646
public const USERAGENT = CURLOPT_USERAGENT;
47-
public const HTTP_VERSION = CURLOPT_HTTP_VERSION;
47+
// public const HTTP_VERSION = CURLOPT_HTTP_VERSION;
4848

4949
/**
5050
* @access private
@@ -428,7 +428,7 @@ public static function request(string $url, array $params = []) : array
428428
// Set options
429429
self::setHeader($handle, $header);
430430
self::setTimeout($handle, $timeout);
431-
self::setOpt($handle, self::HTTP_VERSION, CURL_HTTP_VERSION_1_1);
431+
// self::setOpt($handle, self::HTTP_VERSION, CURL_HTTP_VERSION_1_1);
432432

433433
if ( $encoding ) {
434434
self::setEncoding($handle, $encoding);
@@ -443,6 +443,9 @@ public static function request(string $url, array $params = []) : array
443443
self::verifyPeer($handle, false);
444444
}
445445

446+
// Force HTTP/1.1 to avoid HTTP/2 stream protocol errors
447+
self::setOpt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
448+
446449
if ( $method == Client::POST ) {
447450
self::setPost($handle);
448451
self::setPostData($handle, $body);

src/lib/OAuth.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,8 @@ private function refreshAccessToken() : void
162162

163163
$response = curl_exec($ch);
164164
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
165-
$curlError = curl_error($ch);
166165
curl_close($ch);
167166

168-
if ( $curlError ) {
169-
error_log("OAuth cURL Error: {$curlError}");
170-
}
171-
172167
if ( $httpCode === 200 && $response ) {
173168
$data = json_decode($response, true);
174169

@@ -177,11 +172,12 @@ private function refreshAccessToken() : void
177172
// Set expiration time with a 30-second buffer to match official SDK
178173
$expiresIn = isset($data['expires_in']) ? (int)$data['expires_in'] : 3600;
179174
$this->tokenExpiry = time() + $expiresIn - 30;
175+
} else {
176+
$this->clearToken();
180177
}
181178
} else {
182179
// Clear existing token on failure (official SDK pattern)
183180
$this->clearToken();
184-
error_log("OAuth Error: Failed to get access token. HTTP Code: {$httpCode}");
185181
}
186182
}
187183

0 commit comments

Comments
 (0)