Skip to content

Commit

Permalink
CLI-868: Refresh Tokens are invalidated too frequently while Acquia C…
Browse files Browse the repository at this point in the history
…LI is running (#1214)
  • Loading branch information
danepowell authored Oct 20, 2022
1 parent 7a20b67 commit 31b4fab
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/CloudApi/AccessTokenConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acquia\Cli\CloudApi;

use Acquia\Cli\Exception\AcquiaCliException;
use AcquiaCloudApi\Connector\Connector;
use League\OAuth2\Client\Provider\GenericProvider;
use League\OAuth2\Client\Token\AccessToken;
Expand All @@ -21,14 +22,21 @@ class AccessTokenConnector extends Connector {
* @inheritdoc
*/
public function __construct(array $config, string $base_uri = NULL) {
$this->accessToken = $config['access_token'];
$this->accessToken = new AccessToken(['access_token' => $config['access_token']]);
parent::__construct($config, $base_uri);
}

/**
* @inheritdoc
* @throws \Acquia\Cli\Exception\AcquiaCliException
*/
public function createRequest($verb, $path): RequestInterface {
if ($file = getenv('ACLI_ACCESS_TOKEN_FILE')) {
if (!file_exists($file)) {
throw new AcquiaCliException('Access token file not found at {file}', ['file' => $file]);
}
$this->accessToken = new AccessToken(['access_token' => trim(file_get_contents($file), "\"\n")]);
}
return $this->provider->getAuthenticatedRequest(
$verb,
$this->baseUri . $path,
Expand Down

0 comments on commit 31b4fab

Please sign in to comment.