diff --git a/apps/oauth2/lib/Controller/OauthApiController.php b/apps/oauth2/lib/Controller/OauthApiController.php index ef3912c9b75..835f2fdfd8c 100644 --- a/apps/oauth2/lib/Controller/OauthApiController.php +++ b/apps/oauth2/lib/Controller/OauthApiController.php @@ -181,6 +181,9 @@ class OauthApiController extends Controller { $newToken = $this->secureRandom->generate(72, ISecureRandom::CHAR_ALPHANUMERIC); $newCode = $this->secureRandom->generate(128, ISecureRandom::CHAR_ALPHANUMERIC); $newEncryptedToken = $this->crypto->encrypt($newToken, $newCode); + $redeemedThrottleReason = $grant_type === 'authorization_code' + ? 'authorization_code_already_redeemed' + : 'refresh_token_already_redeemed'; $tokenRotated = false; $this->db->beginTransaction(); @@ -211,7 +214,7 @@ class OauthApiController extends Controller { $response = new JSONResponse([ 'error' => 'invalid_request', ], Http::STATUS_BAD_REQUEST); - $response->throttle(['invalid_request' => 'token already redeemed']); + $response->throttle(['invalid_request' => $redeemedThrottleReason]); return $response; } diff --git a/apps/oauth2/tests/Controller/OauthApiControllerTest.php b/apps/oauth2/tests/Controller/OauthApiControllerTest.php index 57be9062b44..82867a6d0a5 100644 --- a/apps/oauth2/tests/Controller/OauthApiControllerTest.php +++ b/apps/oauth2/tests/Controller/OauthApiControllerTest.php @@ -656,7 +656,7 @@ class OauthApiControllerTest extends TestCase { $expected = new JSONResponse([ 'error' => 'invalid_request', ], Http::STATUS_BAD_REQUEST); - $expected->throttle(['invalid_request' => 'token already redeemed']); + $expected->throttle(['invalid_request' => 'refresh_token_already_redeemed']); $accessToken = new AccessToken(); $accessToken->setId(21);