Skip to content

Commit d7dd781

Browse files
committed
Pass GitHub access token when accessing raw.githubusercontent.com
1 parent 7a79135 commit d7dd781

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Downloader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ private function get(array $urls, bool $isRecipe = false, int $try = 3): array
276276

277277
if (preg_match('{^https?://api\.github\.com/}', $url)) {
278278
$headers[] = 'Accept: application/vnd.github.v3.raw';
279+
} elseif (preg_match('{^https?://raw\.githubusercontent\.com/}', $url) && $this->io->hasAuthentication('github.com')) {
280+
$auth = $this->io->getAuthentication('github.com');
281+
if ('x-oauth-basic' === $auth['password']) {
282+
$headers[] = 'Authorization: token '.$auth['username'];
283+
}
279284
} elseif ($this->legacyEndpoint) {
280285
$headers[] = 'Package-Session: '.$this->sess;
281286
}

0 commit comments

Comments
 (0)