|
@@ 189-196 (lines=8) @@
|
| 186 |
|
if ($accessToken->isExpired($this->dateTime)) { |
| 187 |
|
$this->logger->info(sprintf('access_token for user "%s" with scope "%s" expired', $this->userId, $requestScope)); |
| 188 |
|
// access_token is expired, try to refresh it |
| 189 |
|
if (is_null($accessToken->getRefreshToken())) { |
| 190 |
|
$this->logger->info(sprintf('no refresh_token available in this access_token for user "%s" with scope "%s", deleting it', $this->userId, $requestScope)); |
| 191 |
|
// we do not have a refresh_token, delete this access token, it |
| 192 |
|
// is useless now... |
| 193 |
|
$this->tokenStorage->deleteAccessToken($this->userId, $accessToken); |
| 194 |
|
|
| 195 |
|
return false; |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
$this->logger->info(sprintf('using refresh_token to obtain new access_token for user "%s" with scope "%s"', $this->userId, $requestScope)); |
| 199 |
|
|
|
@@ 217-223 (lines=7) @@
|
| 214 |
|
$request->setHeader('Authorization', sprintf('Bearer %s', $accessToken->getToken())); |
| 215 |
|
|
| 216 |
|
$response = $this->httpClient->send($request); |
| 217 |
|
if (401 === $response->getStatusCode()) { |
| 218 |
|
$this->logger->info(sprintf('deleting access_token for user "%s" with scope "%s" that was supposed to work, but did not, possibly revoked by user', $this->userId, $requestScope)); |
| 219 |
|
// this indicates an invalid access_token |
| 220 |
|
$this->tokenStorage->deleteAccessToken($this->userId, $accessToken); |
| 221 |
|
|
| 222 |
|
return false; |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
$this->logger->info(sprintf('access_token for use "%s" with scope "%s" successfully used', $this->userId, $requestScope)); |
| 226 |
|
|