From ee1691f79968c8dea6275bcb47d39c71b1aff82c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 11 Jan 2013 16:27:33 +0100 Subject: [PATCH] Also try authenticating on github for 403 responses --- src/Composer/Downloader/FileDownloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 2437fd635..fe56e5814 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -106,8 +106,8 @@ class FileDownloader implements DownloaderInterface $this->io->write(' Loading from cache'); } } catch (TransportException $e) { - if (404 === $e->getCode() && 'github.com' === $hostname) { - $message = "\n".'Could not fetch '.$processedUrl.', enter your GitHub credentials to access private repos'; + if (in_array($e->getCode(), array(404, 403)) && 'github.com' === $hostname && !$this->io->hasAuthentication($hostname)) { + $message = "\n".'Could not fetch '.$processedUrl.', enter your GitHub credentials '.($e->getCode === 404 ? 'to access private repos' : 'to go over the API rate limit'); $gitHubUtil = new GitHub($this->io, $this->config, null, $this->rfs); if (!$gitHubUtil->authorizeOAuth($hostname) && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($hostname, $message))