diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php
index 58cfd82d9..5d1965d10 100755
--- a/src/Composer/Repository/Vcs/GitHubDriver.php
+++ b/src/Composer/Repository/Vcs/GitHubDriver.php
@@ -292,6 +292,19 @@ class GitHubDriver extends VcsDriver
$this->io->setAuthorization($this->originUrl, $username, $password);
break;
+ case 403:
+ if (!$this->io->hasAuthorization($this->originUrl)) {
+ if (!$this->io->isInteractive()) {
+ $this->io->write('API limit exhausted. Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your username and password to increase the API limit');
+ throw $e;
+ }
+ $this->io->write('API limit exhausted. Authentication required for larger API limit ('.$this->url.'):');
+ $username = $this->io->ask('Username: ');
+ $password = $this->io->askAndHideAnswer('Password: ');
+ $this->io->setAuthorization($this->originUrl, $username, $password);
+ }
+ break;
+
default:
throw $e;
break;
diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php
index d013e3b66..3555557ee 100644
--- a/src/Composer/Util/RemoteFilesystem.php
+++ b/src/Composer/Util/RemoteFilesystem.php
@@ -207,6 +207,12 @@ class RemoteFilesystem
}
break;
+ case STREAM_NOTIFY_AUTH_RESULT:
+ if (403 === $messageCode) {
+ throw new TransportException($message, 403);
+ }
+ break;
+
case STREAM_NOTIFY_FILE_SIZE_IS:
if ($this->bytesMax < $bytesMax) {
$this->bytesMax = $bytesMax;