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

Fetch new access tokens if refreshing token returns "invalid_grant" #1729

Merged
merged 1 commit into from Oct 31, 2019

Conversation

@Lavoaster
Copy link
Contributor

Lavoaster commented Oct 13, 2019

I know the PR says to open an issue first, but I figured this could be the discussion as I've already done part of the work.

At my current workplace we have an oauth server with access tokens on a 5 min TTL and refresh tokens on a 30 min TTL. So every so often I'll see the following message.

Screenshot 2019-10-13 23 48 56

It's rather annoying to have to go into the OAuth page to clear the tokens and refresh it again. Given Insomnia automatically handles fetching the access / refresh. I'm sure it should be able to ignore this and fetch new tokens if it encounters this error.

So, as per the oauth spec here, I've updated the refreshToken function to return the magic response that will trigger a new token to be fetched if the server sends back 400 status, and the error in the json body is invalid_grant.

I'm not sure how to go about testing this, so if you want test point me in the right direction and I'll take a shot.

@welcome

This comment has been minimized.

Copy link

welcome bot commented Oct 13, 2019

💖 Thanks for opening this pull request! 💖

To help make this a smooth process, please be sure you have first read the
contributing guidelines.

@Lavoaster

This comment has been minimized.

Copy link
Contributor Author

Lavoaster commented Oct 18, 2019

@gschier Have you had a chance to look at this or consider if this is a feature you want in insomnia?

Copy link
Contributor

gschier left a comment

I like it! Since it's part of the OAuth spec, I'm fine merging it :)

@gschier gschier merged commit c88eb12 into Kong:develop Oct 31, 2019
1 check failed
1 check failed
continuous-integration/appveyor/pr AppVeyor build failed
Details
@welcome

This comment has been minimized.

Copy link

welcome bot commented Oct 31, 2019

Congrats on merging your first pull request! 🎉🎉🎉 You're helping make Insomnia awesome! 🙌

@Lavoaster Lavoaster deleted the Lavoaster:feature/refresh_on_invalid_grant branch Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.