function Bitbucket::requestToken
Retrieves an access token from Bitbucket.
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Bitbucket.php, line 195
Class
- Bitbucket
- @author Paul Wenke <wenke.paul@gmail.com>
Namespace
Composer\UtilCode
public function requestToken(string $originUrl, string $consumerKey, string $consumerSecret) : string {
if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
return $this->token['access_token'];
}
$this->io
->setAuthentication($originUrl, $consumerKey, $consumerSecret);
if (!$this->requestAccessToken()) {
return '';
}
$this->storeInAuthConfig($this->config
->getLocalAuthConfigSource() ?? $this->config
->getAuthConfigSource(), $originUrl, $consumerKey, $consumerSecret);
if (!isset($this->token['access_token'])) {
throw new \LogicException('Failed to initialize token above');
}
return $this->token['access_token'];
}