From 2cb07dd2fe8f03b52f742ffd34c83342d041160e Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Sun, 21 Oct 2012 01:06:56 +0100 Subject: [PATCH] Allow use of Github OAuth2 token stored in git config --- src/Composer/Repository/Vcs/GitHubDriver.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index b31326deb..af2acd15d 100755 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -350,6 +350,15 @@ class GitHubDriver extends VcsDriver protected function authorizeOAuth() { + // If available use token from git config + exec('git config github.accesstoken', $output, $returnCode); + if ($returnCode === 0 && !empty($output[0])) + { + $this->io->write('Using Github OAuth token stored in git config (github.accesstoken)'); + $this->io->setAuthorization($this->originUrl, $output[0], 'x-oauth-basic'); + return; + } + $attemptCounter = 0; $this->io->write('The credentials will be swapped for an OAuth token stored in '.$this->config->get('home').'/config.json, your password will not be stored');