Sharing auth method #3518
-
Describe the solution you'd like
Describe alternatives you've considered Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 12 replies
-
Welcome @Bogidon 👋 Oh, I see, something like a shared authentication store that you could reference on requests? Seems like a really good idea actually. I'm wondering if it could be used more than just authentication. @gschier is there anything like this in the app currently? |
Beta Was this translation helpful? Give feedback.
-
There was a discussion a long time ago under the feature "Parent Requests" but it was abandoned for various reasons: #598 For OAuth 2.0, specifically, someone has created a plugin that allows referencing the Access Token from a different request. That way you only have to define the information once. This should solve your immediate problem of manually copying the token into the environment: https://insomnia.rest/plugins/insomnia-plugin-accesstoken In general, I like the idea of being able to reference parts of other requests. I think this provides the most flexibility while not overcomplicating the existing UI/UX. |
Beta Was this translation helpful? Give feedback.
-
👋 In general +1 to referencing parts of other requests. Though, to me the clearest way for auth to work would be if you can declare an auth strategy that can be applied to multiple requests, that would internally only rerun as necessary. That would remove the "oh you have to run this special request first". Thanks for the plugin. I tried a different one a while ago that I couldn't get working, so I'll give this one a shot. |
Beta Was this translation helpful? Give feedback.
-
@gschier @nijikokun ping that we'd likely pay for Insomnia were this implemented. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Would be really cool to be able to copy-paste Auth from one endpoint to others. For example, I setup Auth as Bearer and specify token to be used from response body of another endpoint. Now I can copy-paste token value, but still have to choose Auth -> Bearer, and then paste token value. What would make it simpler is to copy whole Auth settings, and then paste them to another endpoints with some hotkey/context menus. Or better — to link Auth to one of endpoints, so it can be updated later in a single place. Maybe mark endpoint with "auth" label then for visual distinction etc. Postman for example can inherit Auth. |
Beta Was this translation helpful? Give feedback.
-
After starting with insomnia, I was very happy to see the OAuth2 authentication working with our internal OAuth2 provider - even the authorization code flow works 🎉 . Not sure though how to pair this with the different environments. We have one OAuth2 provider per environment (staging, production) and this should be switched also when changing the environment. |
Beta Was this translation helpful? Give feedback.
-
This is the main thing preventing us from switching from Postman. |
Beta Was this translation helpful? Give feedback.
-
Hello, We will look into folder-level authentications, global environments immediately after the release of v9.0 at the end of the month. These capabilities are top of mind. |
Beta Was this translation helpful? Give feedback.
-
Aiming to deliver this in #7353 |
Beta Was this translation helpful? Give feedback.
-
A potential workaround here (for Auth0 at least), is to make a Token Refresh request to It's gnarly, and not my favorite solution as it results in a token refresh immediately after login, but it does work. Configure OAuth2 authentication on this one request like you normally would. Insomnia will kick off the OAuth2 workflow as normal, log you in, fetch the tokens, and then initiate the token refresh giving you a JSON response payload that you can chain forward. Access token request: {
"grant_type": "refresh_token",
"client_id": "{{ _.Auth.ClientId }}",
"refresh_token": "{% request 'oauth2-refresh', '', 0 %}"
} Example response: {
"access_token": "ey...",
"refresh_token": "v1...",
"id_token": "ey...",
"scope": "openid profile email offline_access",
"expires_in": 900,
"token_type": "Bearer"
} Subsequent request chaining would use Bearer Auth using the response body attribute, something like:
|
Beta Was this translation helpful? Give feedback.
-
We have shipped folder-level authentication, and pre-request and after-response scripting capabilities in Insomnia 9.x, which should allow us to solve for this use-case by creating a folder with the desired authentication mechanism for all the requests that are placed within. |
Beta Was this translation helpful? Give feedback.
-
I'm seeing the same issue (with my requests under a top-level folder): |
Beta Was this translation helpful? Give feedback.
-
Can confirm. Also ran into this bug today. It's tricky, because it does send a token, it's just an ID token instead of the Access token, even if you select 'Access token' only in the OAuth2 response type. I guess it's the same/related bug as this one: #7880 ? |
Beta Was this translation helpful? Give feedback.
-
I'm experiencing similar issues on 10.1.0: My requests that inherit OAuth2 seem to grab the first token and hold onto it forever. Changing environments, clearing the parent's tokens, etc. have no effect. Duplicating the request within the folder does work to pick up the new token, but it ultimately defeats the purpose of this feature. |
Beta Was this translation helpful? Give feedback.
We have shipped folder-level authentication, and pre-request and after-response scripting capabilities in Insomnia 9.x, which should allow us to solve for this use-case by creating a folder with the desired authentication mechanism for all the requests that are placed within.