diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 882ff4bce..15b1cf9bf 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -101,6 +101,10 @@ class RemoteFilesystem $this->lastProgress = null; $options = $this->getOptionsForUrl($originUrl, $additionalOptions); + if (isset($options['github-token'])) { + $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token']; + unset($options['github-token']); + } $ctx = StreamContextFactory::getContext($options, array('notification' => array($this, 'callbackGet'))); if ($this->progress) { @@ -281,8 +285,12 @@ class RemoteFilesystem if ($this->io->hasAuthentication($originUrl)) { $auth = $this->io->getAuthentication($originUrl); - $authStr = base64_encode($auth['username'] . ':' . $auth['password']); - $headers[] = 'Authorization: Basic '.$authStr; + if ('github.com' === $originUrl && 'x-oauth-basic' === $auth['password']) { + $options['github-token'] = $auth['username']; + } else { + $authStr = base64_encode($auth['username'] . ':' . $auth['password']); + $headers[] = 'Authorization: Basic '.$authStr; + } } $options = array_replace_recursive($this->options, $additionalOptions);