From 9ddf8c4d55851c3a71da3cacddce7d60945318f1 Mon Sep 17 00:00:00 2001 From: "Paul.Wenke" Date: Sun, 13 Mar 2016 16:57:23 -0400 Subject: [PATCH] Fixed OAuth credentials issue for subsequent clone requests. --- src/Composer/Util/Git.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index d63bdd468..b839bdc56 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -114,7 +114,7 @@ class Git return; } } - } elseif (preg_match('{^(?:https?|git)://'.self::getBitbucketDomainsRegex($this->config).'/(.*)\.git}', $url, $match)) { //bitbucket oauth + } elseif (preg_match('{^(?:https?|git)://'.self::getBitbucketDomainsRegex($this->config).'/(.*)}', $url, $match)) { //bitbucket oauth $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process); if (!$this->io->hasAuthentication($match[1])) { @@ -127,8 +127,12 @@ class Git } } else { //We're authenticating with a locally stored consumer. $auth = $this->io->getAuthentication($match[1]); - $token = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']); - $this->io->setAuthentication($match[1], 'x-token-auth', $token['access_token']); + + //We already have an access_token from a previous request. + if($auth['username'] !== 'x-token-auth') { + $token = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']); + $this->io->setAuthentication($match[1], 'x-token-auth', $token['access_token']); + } } if ($this->io->hasAuthentication($match[1])) {