0

I have a .Net Core2 webapi in which I have a user/pass authentication to issue a short lived jwt (5 min) which includes a long session revocable refresh token. When the jwt expires, the webapi checks if there is a refresh available and if there is, it returns the new token

On the client side, I want to place a global hook on any ajax calls to catch the case where a 401 is returned, but with a new token. This hook would simply reset the token and resubmit the request.

Is the best way to do this ajaxSetup? Example would be appreciated. Any issues anyone can see with this approach?

statler
  • 1,322
  • 2
  • 15
  • 24
  • Possible duplicate of [Add a "hook" to all AJAX requests on a page](https://stackoverflow.com/questions/5202296/add-a-hook-to-all-ajax-requests-on-a-page) – Artsiom Miksiuk Sep 09 '17 at 13:01
  • Not a dupe. This question is different in two specific ways; 1. It isnt restricted to pure JS. I expect the most readable/easily implemented solution involves JQuery 2. I specifically want to know how to automatically resubmit the original request with a new header – statler Sep 10 '17 at 21:08

0 Answers0