A
A
aresht2016-01-06 11:10:04
JavaScript
aresht, 2016-01-06 11:10:04

How to redo last action after refresh token in AngularJS?

I'm learning AngularJS, I ran into such a problem...
There is a table on the UI-Grid, after the token goes bad and the server returns a 401 response, I update the token. I used HttpInterceptor for this, the token is updated normally, but the problem is that the request that was before the token was updated (let's go to the next page in the table) is already lost and needs to be repeated somehow after the update. I tried to save the unsuccessful request in cookies and repeat it after updating the token, but the request is simply executed and that's it. That is, the data is received, but there is no longer a connection with the table.
How to be in that case and repeat the last unsuccessful request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-01-06
@aresht

see angular-http-auth, there is an implementation of retrying requests.
But in the case of refresh tokens, there should be a slightly different approach. You must write an interceptor that, before the request, will itself check whether the token needs to be refreshed, and if so, chain the promise. That is, the refresh token should be used before and not after the authorization fails.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question