Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh provider token if it is expired #33

Merged
merged 1 commit into from
Apr 27, 2024
Merged

Refresh provider token if it is expired #33

merged 1 commit into from
Apr 27, 2024

Conversation

jdgarcia
Copy link
Contributor

GitLab, Bitbucket, and Azure stop working after a few hours since their tokens need to be refreshed. This is similar to what gk.dev does.

src/gkApi.ts Outdated
@@ -138,7 +159,12 @@ export const fetchProviderToken = async (provider: Provider) => {
}

const payload = await res.json();
return payload.data as ProviderToken;
const providerToken = payload.data as ProviderToken;
if (providerToken.expiresIn < 0 && providerToken.type === 'oauth' && provider !== 'github') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why we are excluding github here explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub tokens don't need to be refreshed, they don't expire

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah it's just the way it's written is weird, cause it checks github at the end after it already checks expiresIn

@jdgarcia jdgarcia merged commit 680ce0e into main Apr 27, 2024
1 check passed
@jdgarcia jdgarcia deleted the refresh-token branch April 27, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants