function GitBitbucketDriver::fetchWithOAuthCredentials
Get the remote content.
@phpstan-impure
Parameters
string $url The URL of content:
Return value
Response The result
File
-
vendor/
composer/ composer/ src/ Composer/ Repository/ Vcs/ GitBitbucketDriver.php, line 391
Class
- GitBitbucketDriver
- @author Per Bernhardt <plb@webfactory.de>
Namespace
Composer\Repository\VcsCode
protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false) : Response {
try {
return parent::getContents($url);
} catch (TransportException $e) {
$bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
if (in_array($e->getCode(), [
403,
404,
], true) || 401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0) {
if (!$this->io
->hasAuthentication($this->originUrl) && $bitbucketUtil->authorizeOAuth($this->originUrl)) {
return parent::getContents($url);
}
if (!$this->io
->isInteractive() && $fetchingRepoData) {
$this->attemptCloneFallback();
return new Response([
'url' => 'dummy',
], 200, [], 'null');
}
}
throw $e;
}
}