Insomnia Version: 5.1.0Operating System: MacOS 10.11.3Summary: Switching environments retains OAuth 2 refresh and access tokens when they may no longer be valid.This seems like a large frustration, thanks for pointing it out @nathanwaldman.
At the moment, tokens are stored per request, not per URL. Perhaps it would be better to key them on request+hostname which would provide the experience you are looking for.
The simple workaround is to clear the token on the request, so this isn't high priority. Your suggestion of tying the token to the request+hostname would solve my issue. In general, maybe it has to be tied to the request+username+hostname?
Ya, you are probably correct. The values used to generate the key might depend on what Grant Type is used.
I also run into this issue constantly when switching environments.
While the proposed solution would work, I always thought it was a little weird to setup OAuth on a per-request basis. I had to copy my OAuth config across my entire set of APIs, even though they all shared the same authentication system, being part of the same API.
In other words, I was thinking that a better way to solve this would be to have the Authentication be linked to something more high-level than the request (like environment), so that when you switch to a different environment, the tokens would also switch.
Yeah, I often duplicate an existing request so that I don't have to reconfigure the OAuth security.
Clearing or refreshing Access Tokens on Environment switch would make a better UX than current.
Would love to see folder-based authentication. Having imported a collection from Postman I now need to update the authentication settings for each request separately, which is quite tedious.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
We need this feature to share access tokens between request without reconfiguring all requests. We'd like to have a single request to autenticate, which will save the token in the environment, then use that environment variable as bearer on all other requests
We would use those token even on separate endpoints
@t-ricci-molecle, I'm not sure this issue would help you do that (maybe provide more details on your use case if you think it does). It sounds like what you're after is reusable authentication.
You _can_ already create an authentication request manually and use Chaining to reference a value from it's response in other requests.
@gschier nope, not helpful with OAuth 2.0 (Auth0 in my case, which also requires custom GET query parameters which I cannot set in the Insomnia OAuth 2.0 autentication)
@t-ricci-molecle that make sense. I'm still not sure how what you describe relates to this issue, though. Can you elaborate?
Feel free to create a separate issue describing your use case.
Clearing or refreshing Access Tokens on Environment switch would make a better UX than current.
I would love to see this added. Currently we have several environments (that all share the same pattern): dev, sandbox, staging, demo, prod, prod europe, etc.
They are all different environments and have different id's/secrets. Clearing the token on environment switch (per audvin's comment above) would work great for what I'm doing.
I'm surprised this is closed. I think a big reason why people are switching to Insomnia from Postman is because of the more convenient token generating, only to find that it's still not totally convenient.
Reopening this!
The simple workaround is to clear the token on the request, so this isn't high priority. Your suggestion of tying the token to the request+hostname would solve my issue. In general, maybe it has to be tied to the request+username+hostname?
How would one implement this workaround? Would I use a plugin that evaluates some script before running a request?
We need the ability to clear tokens because we have users with different credentials and different stages. We often have to switch between them and cannot use Insomnia without the ability to clear the token cache (or having it cache the value including the username)...
@nathanwaldman @gschier
How would one implement this workaround? I still don't see how that would work, because I'm not aware how to access Insomnia token cache (and where I could trigger such a script)...
I would argue this has a higher priority if there's no workaround. For us it's a block before we could use Insomnia.
@kossmoboleat for my use case, for a particular request on the Auth/OAuth2.0 tab I just need to remember to click the "Clear" button after switching environments. Then when I send the request Insomnia will re-fetch the access token.
@nathanwaldman Ah right, that works. For some reason I didn't think of looking there. I had been experimenting with the env authentication plugin which of course has no UI...
At the moment, tokens are stored per request, not per URL. Perhaps it would be better to key them on request+hostname which would provide the experience you are looking for.
I'm kinda having a bad experience due to something similar to this.
Imagine this workflow happening in a few minutes
It would be nice if the Tokens were stored between different Envs and switching back and forth between Evns before their expiration doesn't force me to get a new Token (and having to Login and 2FA every single time I change Env which is quite annoying and time consuming).
EDIT: IDK if it is possible, but having the different Login+2FA cookies/sessions stored between the different Envs (to Refresh the tokens) would be awesome too. I usually have an awesome User experience if I don't switch Envs, but switching Envs is a pain.
It would greatly improve the UX to either automatically clear the auth tokens on env switching or support storing auth tokens by env.
Most helpful comment
Reopening this!