You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This method is used using the OAuth Client Credentials Flow for machine-to-machine applications.
215
+
* Therefore the grant type must be Authorization::GRANT_CLIENT_CREDENTIALS. You need to specify the
206
216
* client identifier and client secret and may optionally specify a scope.
207
217
*
208
218
* @param string $serviceName
209
219
* @param string $clientId Client ID
210
220
* @param string $clientSecret Client Secret
211
221
* @param string $scope Scope which may consist of multiple identifiers, separated by comma
212
-
* @param string $grantType One of the Authorization::GRAND_* constants
213
222
* @param array $additionalParameters Additional parameters to provide in the request body while requesting the token. For example ['audience' => 'https://www.example.com/api/v1']
$this->logger->info(sprintf('OAuth (%s): Retrieving access token using %s grant for client "%s" using a %s bytes long secret. (authorization id: %s)', $this->getServiceType(), $grantType, $clientId, strlen($clientSecret), $authorizationId));
$this->logger->info(sprintf('OAuth (%s): Retrieving access token using client credentials grant for client "%s" using a %s bytes long secret. (authorization id: %s)', $this->getServiceType(), $clientId, strlen($clientSecret), $authorizationId));
$this->logger->info(sprintf('OAuth (%s): Starting authorization %s using client id "%s", a %s bytes long secret and scope "%s".', $this->getServiceType(), $authorization->getAuthorizationId(), $clientId, strlen($clientSecret), $scope));
@@ -315,6 +325,10 @@ public function finishAuthorization(string $stateIdentifier, string $code, strin
315
325
thrownewOAuthClientException(sprintf('OAuth2 (%s): Finishing authorization failed because authorization %s could not be retrieved from the database.', $this->getServiceType(), $authorizationId), 1568710771);
316
326
}
317
327
328
+
if ($authorization->getGrantType() !== Authorization::GRANT_AUTHORIZATION_CODE) {
329
+
thrownewOAuthClientException(sprintf('OAuth2 (%s): Finishing authorization failed because authorization %s does not have the authorization code flow type!', $this->getServiceType(), $authorizationId), 1597312780);
330
+
}
331
+
318
332
$this->logger->debug(sprintf('OAuth (%s): Retrieving an OAuth access token for authorization "%s" in exchange for the code %s', $this->getServiceType(), $authorizationId, str_repeat('*', strlen($code) - 3) . substr($code, -3, 3)));
$this->logger->info(sprintf('OAuth (%s): Persisting OAuth token for authorization "%s" with expiry time %s.', $this->getServiceType(), $authorizationId, $accessToken->getExpires()));
@@ -333,7 +347,7 @@ public function finishAuthorization(string $stateIdentifier, string $code, strin
thrownewOAuthClientException(sprintf('OAuth2: Could not refresh OAuth token because authorization %s was not found in our database.', $authorization), 1505317044316);
$this->logger->info(sprintf('OAuth (%s): Refreshing authorization %s for client "%s" using a %s bytes long secret and refresh token "%s".', $this->getServiceType(), $authorizationId, $clientId, strlen($authorization->getClientSecret()), $authorization->refreshToken));
360
376
@@ -375,6 +391,8 @@ public function refreshAuthorization(string $authorizationId, string $clientId,
375
391
}
376
392
377
393
/**
394
+
* Returns the specified Authorization record, if it exists
395
+
*
378
396
* @param string $authorizationId
379
397
* @return Authorization|null
380
398
*/
@@ -463,23 +481,6 @@ public function renderFinishAuthorizationUri(): string
0 commit comments