public function OauthTokenFileStorage::saveToken in Apigee Edge 8
2 calls to OauthTokenFileStorage::saveToken()
File
- src/
OauthTokenFileStorage.php, line 163
Class
- OauthTokenFileStorage
- Stores OAuth token data in a file.
Namespace
Drupal\apigee_edgeCode
public function saveToken(array $data) : void {
// Calculate the cache expiration.
if (isset($data['expires_in'])) {
$data['expires'] = $data['expires_in'] + time();
}
// Do not save the expires_in data to the storage.
unset($data['expires_in']);
try {
$this
->checkRequirements();
// Write the obfuscated token data to a private file.
$this->fileSystem
->saveData(base64_encode(serialize($data)), $this->tokenFilePath, FileSystemInterface::EXISTS_REPLACE);
} catch (FileException $e) {
$this->logger
->critical('Error saving OAuth token file.');
} catch (OauthTokenStorageException $exception) {
$this->logger
->critical('OAuth token file storage: %error.', [
'%error' => $exception
->getMessage(),
]);
} finally {
// Even if an error occurs here token data can be still served from the
// internal cache in this page request.
$this->tokenData = $data;
}
}