Our server provides 5 minute session tokens. Currently I can either (1) manually send a login request to save the session environment variable when I want a new token or (2) configure insomnia to login every time I send any request.
There are occasional other problems with using a new session token every time, which precludes always using option 2 for me.
I would like to configure the session environment variable to:
This would avoid spamming the server with login requests but also avoid the annoying manual session refresh. The feature seems general enough that it would be useful for other authentication mechanisms or dependent request triggering.
Since this is such a specific use-case, I suggest writing a plugin to accomplish what you need. For example, you could have a plugin that stores its own token and manually refreshes it (if needed) on the "request hook" event. You could also fork the current Response plugin to add the functionality needed as well.
@gschier This is not a specific case, when working with a authenticated API is a common case to have to refresh tokens after several minutes.
I'm chaining my request using a response tag requesting to my token server with trigger behavior to "no history" and sometimes I have to manually refresh the token.
It would be very useful to have a trigger option "expire after..."
I took at stab at implementing this (#2284) and it turned out to be simple and, I think, generally useful when dealing with any time-sensitive API.
Most helpful comment
@gschier This is not a specific case, when working with a authenticated API is a common case to have to refresh tokens after several minutes.
I'm chaining my request using a response tag requesting to my token server with trigger behavior to "no history" and sometimes I have to manually refresh the token.
It would be very useful to have a trigger option "expire after..."