Skip to content

Commit 7fbaf44

Browse files
authored
Merge pull request #1028 from supertokens/fix/oauth-refresh-token-bug
fix: return the proper response when the OAuth2 refresh token is invalid
2 parents 0fe0ab5 + caea4df commit 7fbaf44

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Fix WebAuthn credential listing and removal to work even when the WebAuthn user is not the primary user and when there are multiple WebAuthn users linked
1616
- Prevent removal of WebAuthn credentials unless all session claims are satisfied
1717
- Change how sessions are fetched before listing, removing and adding WebAuthn credentials
18+
- Fix the OAuth2Provider `tokenExchange` error message when the refresh token is expired
1819

1920
## [23.0.0] - 2025-07-21
2021

lib/build/recipe/oauth2provider/recipeImplementation.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/oauth2provider/recipeImplementation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,16 @@ export default function getRecipeInterface(
471471
return tokenInfo;
472472
}
473473

474+
if (!tokenInfo.active) {
475+
return {
476+
status: "ERROR",
477+
statusCode: 400,
478+
error: "invalid_grant",
479+
errorDescription:
480+
"The provided refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
481+
};
482+
}
483+
474484
if (tokenInfo.active === true) {
475485
const sessionHandle = tokenInfo.sessionHandle as string;
476486

0 commit comments

Comments
 (0)