Closed nimatrazmjo closed 6 years ago
your service should return proper status back to understand that error occurred because of the expired auth token, let's say it should return not just 401 but also error code, because 401 it's very generic status code which can mean that access token is expired and also refresh token, or they both invalid etc. So in your method, refreshShouldHappend
you should carefully and correctly handle this case. Here's the real-world example:
public refreshShouldHappen(response: HttpErrorResponse): boolean {
const responseCode: number = response.error.code;
return response.status === 401 && [10001, 10002, 10003].indexOf(responseCode) >= 0;
}
So refresh request will happened in case if request status is 401 and error code can be one of those 10001, 10002, 10003 codes.
Plus just incase check example repo and see the other possible options, and don't forget to check again README.md file
user.service.ts
It keeps refreshing.