mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 22:40:26 +01:00
Catch any 4XX error on refresh token failure
https://feedback.yaak.app/p/folders-oauth2-refresh-token-issue
This commit is contained in:
@@ -71,10 +71,10 @@ export async function getOrRefreshAccessToken(
|
|||||||
httpRequest.authenticationType = 'none'; // Don't inherit workspace auth
|
httpRequest.authenticationType = 'none'; // Don't inherit workspace auth
|
||||||
const resp = await ctx.httpRequest.send({ httpRequest });
|
const resp = await ctx.httpRequest.send({ httpRequest });
|
||||||
|
|
||||||
if (resp.status === 401) {
|
if (resp.status >= 400 && resp.status < 500) {
|
||||||
// Bad refresh token, so we'll force it to fetch a fresh access token by deleting
|
// Client errors (4xx) indicate the refresh token is invalid, expired, or revoked
|
||||||
// and returning null;
|
// Delete the token and return null to trigger a fresh authorization flow
|
||||||
console.log('[oauth2] Unauthorized refresh_token request');
|
console.log('[oauth2] Refresh token request failed with client error, deleting token');
|
||||||
await deleteToken(ctx, tokenArgs);
|
await deleteToken(ctx, tokenArgs);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user