Skip to content

Commit

Permalink
Fix issue with refresh token logic
Browse files Browse the repository at this point in the history
The API was updated so that expiresIn can no longer be below 0.
  • Loading branch information
jdgarcia committed May 6, 2024
1 parent ff2ec61 commit 066fc68
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gkApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export const fetchProviderToken = async (provider: Provider) => {
const payload = await res.json();
const providerToken = payload.data as ProviderToken;
// Attempt to refresh expired OAuth tokens. Note: GitHub tokens don't expire.
if (provider !== 'github' && providerToken.expiresIn < 0 && providerToken.type === 'oauth') {
// We also refresh tokens that are about to expire in 60 seconds (expiresIn is in seconds).
if (provider !== 'github' && providerToken.expiresIn < 60 && providerToken.type === 'oauth') {
return refreshProviderToken(provider);
}

Expand Down

0 comments on commit 066fc68

Please sign in to comment.