E6 API: Set up Automatic Access Token (Bearer) in Insomnia (Chaining Requests)

Note: if you are on Postman, this page does not apply to you, you can ignore it!

1.) Create a POST request to obtain your access token. In this example, I have used E6’s login endpoint (Refer to E6 login credentials)Notice that the response key is tokenId. This is the access token we will need in step 3.

2.) Create a second request (It can either be POST or GET) for the API that would return the data for you. In the Bearer tab, type in Response => Body Attribute (Insomnia will auto-fill).

3.) Next step, click on the Response => Body Attribute. An Edit Tag dialog will pop-up. In Request field, select the request you created instep 1 (E6’s login request) from the drop-down. Next, in the Filter (JSONPath or XPath) field, type in type in the $.[attribute name] – where attribute name is the response that returns from authentication call (i.e., $.tokenId). Lastly, select Always – resend request when needed from Trigger Behavior drop-down.

That’s it! You can now automatically pass access token to every request that needs authentication in your Insomnia by following the above instructions.

Source: https://docs.insomnia.rest/insomnia/chaining-requests

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.