Make authenticated requests with Insomnia

Make authenticated requests with Insomnia

How to make requests to authenticated URLs without copying tokens back and forth.

Do you also have to call protected routes for testing or debugging reasons with tools like Postman or Insomnia?

I have to do it currently quite extensively and having short living JWTs is not making the situation any more convenient.

But there is always a solution. First I thought about automating that on my own but before I checked the Insomnia docs and found the exact solution I was looking for: Chaining Requests

Chaining requests allows you to perform an additional request before the actual request is being sent. It's super easy to use and it doesn't matter where the token is included in the login response. It can be retrieved via the response header or body or inside a defined cookie jar.

I created a little demo server to show how this works:

Source files:

Finding this method was one of those eye opening moments where I wasted so much time before when the solution was always there and so convenient 🤯 Hopefully I can save someone some minutes with clicking and pasting tokens around 😊