Skip to content

Commit 53afca7

Browse files
Add header if API_TOKEN is present
1 parent 96d8b2f commit 53afca7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/php/libsdk/SDK/FileOps.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ protected function download(string $url, string $dest_fn = NULL) : ?string
138138
curl_setopt($ch, CURLOPT_USERAGENT, Config::getSdkUserAgentName());
139139
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
140140

141+
$token = getenv('API_TOKEN');
142+
if (!empty($token)) {
143+
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$token]);
144+
}
145+
141146
// workaround for <https://github.com/microsoft/php-sdk-binary-tools/issues/69>
142147
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
143148

0 commit comments

Comments
 (0)