function GitLab::authorizeOAuthRefresh
Authorizes a GitLab domain interactively via OAuth.
Parameters
string $scheme Scheme used in the origin URL:
string $originUrl The host this GitLab instance is located at:
Return value
bool true on success
Throws
\RuntimeException
TransportException|\Exception
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ GitLab.php, line 209
Class
- GitLab
- @author Roshan Gautam <roshan.gautam@hotmail.com>
Namespace
Composer\UtilCode
public function authorizeOAuthRefresh(string $scheme, string $originUrl) : bool {
try {
$response = $this->refreshToken($scheme, $originUrl);
} catch (TransportException $e) {
$this->io
->writeError("Couldn't refresh access token: " . $e->getMessage());
return false;
}
$this->io
->setAuthentication($originUrl, $response['access_token'], 'oauth2');
// store value in user config in auth file
$this->config
->getAuthConfigSource()
->addConfigSetting('gitlab-oauth.' . $originUrl, [
'expires-at' => intval($response['created_at']) + intval($response['expires_in']),
'refresh-token' => $response['refresh_token'],
'token' => $response['access_token'],
]);
return true;
}