diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 34e3f20b4..91402748f 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -69,7 +69,12 @@ public function respondToAccessTokenRequest( } } - $scopes = $this->scopeRepository->finalizeScopes($scopes, $this->getIdentifier(), $client); + $userId = $oldRefreshToken['user_id']; + if (is_int($userId)) { + $userId = (string) $userId; + } + + $scopes = $this->scopeRepository->finalizeScopes($scopes, $this->getIdentifier(), $client, $userId); // Expire old tokens $this->accessTokenRepository->revokeAccessToken($oldRefreshToken['access_token_id']); @@ -78,10 +83,6 @@ public function respondToAccessTokenRequest( } // Issue and persist new access token - $userId = $oldRefreshToken['user_id']; - if (is_int($userId)) { - $userId = (string) $userId; - } $accessToken = $this->issueAccessToken($accessTokenTTL, $client, $userId, $scopes); $this->getEmitter()->emit(new RequestAccessTokenEvent(RequestEvent::ACCESS_TOKEN_ISSUED, $request, $accessToken)); $responseType->setAccessToken($accessToken); diff --git a/tests/Grant/RefreshTokenGrantTest.php b/tests/Grant/RefreshTokenGrantTest.php index 1fe1eadab..165f66e70 100644 --- a/tests/Grant/RefreshTokenGrantTest.php +++ b/tests/Grant/RefreshTokenGrantTest.php @@ -573,7 +573,7 @@ public function testRespondToRequestFinalizeScopes(): void $scopeRepositoryMock ->expects(self::once()) ->method('finalizeScopes') - ->with($scopes, $grant->getIdentifier(), $client) + ->with($scopes, $grant->getIdentifier(), $client, '123', null) ->willReturn($finalizedScopes); $accessToken = new AccessTokenEntity();