Skip to content

Pass GitHub access token when accessing raw.githubusercontent.com in case of private recipes #842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Pass GitHub access token when accessing raw.githubusercontent.com
  • Loading branch information
aivus committed Dec 1, 2021
commit d7dd78155cd1ec0a22230f1cc8221e82ea4d6c04
5 changes: 5 additions & 0 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ private function get(array $urls, bool $isRecipe = false, int $try = 3): array

if (preg_match('{^https?://api\.github\.com/}', $url)) {
$headers[] = 'Accept: application/vnd.github.v3.raw';
} elseif (preg_match('{^https?://raw\.githubusercontent\.com/}', $url) && $this->io->hasAuthentication('github.com')) {
$auth = $this->io->getAuthentication('github.com');
if ('x-oauth-basic' === $auth['password']) {
$headers[] = 'Authorization: token '.$auth['username'];
}
} elseif ($this->legacyEndpoint) {
$headers[] = 'Package-Session: '.$this->sess;
}
Expand Down