@@ 189-193 (lines=5) @@ | ||
186 | } |
|
187 | ||
188 | // make sure we have an access token |
|
189 | if (false === $accessToken = $this->tokenStorage->getAccessToken($this->userId, $this->providerId, $requestScope)) { |
|
190 | $this->logger->info(sprintf('no access_token available for user "%s" with scope "%s"', $this->userId, $requestScope)); |
|
191 | ||
192 | return false; |
|
193 | } |
|
194 | ||
195 | if ($requestScope !== $accessToken->getScope()) { |
|
196 | throw new OAuthException('access_token does not have the required scope'); |
|
@@ 203-210 (lines=8) @@ | ||
200 | if ($accessToken->isExpired($this->dateTime)) { |
|
201 | $this->logger->info(sprintf('access_token for user "%s" with scope "%s" expired', $this->userId, $requestScope)); |
|
202 | // access_token is expired, try to refresh it |
|
203 | if (is_null($accessToken->getRefreshToken())) { |
|
204 | $this->logger->info(sprintf('no refresh_token available in this access_token for user "%s" with scope "%s", deleting it', $this->userId, $requestScope)); |
|
205 | // we do not have a refresh_token, delete this access token, it |
|
206 | // is useless now... |
|
207 | $this->tokenStorage->deleteAccessToken($this->userId, $this->providerId, $accessToken); |
|
208 | ||
209 | return false; |
|
210 | } |
|
211 | ||
212 | $this->logger->info(sprintf('using refresh_token to obtain new access_token for user "%s" with scope "%s"', $this->userId, $requestScope)); |
|
213 | ||
@@ 231-237 (lines=7) @@ | ||
228 | $request->setHeader('Authorization', sprintf('Bearer %s', $accessToken->getToken())); |
|
229 | ||
230 | $response = $this->httpClient->send($request); |
|
231 | if (401 === $response->getStatusCode()) { |
|
232 | $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)); |
|
233 | // this indicates an invalid access_token |
|
234 | $this->tokenStorage->deleteAccessToken($this->userId, $this->providerId, $accessToken); |
|
235 | ||
236 | return false; |
|
237 | } |
|
238 | ||
239 | $this->logger->info(sprintf('access_token for use "%s" with scope "%s" successfully used', $this->userId, $requestScope)); |
|
240 |