-
Notifications
You must be signed in to change notification settings - Fork 4
Description
If have stumbled on a case where AuthenticationManager.authenticated is true, but the underlying tokens expired, and had a failure after calling an api method.
Calling refreshTokens() worked, after calling it, api methods are once again returning expected results.
I wish I could get the exact error I received for "stale tokens", but I have to wait for them to expire, not sure how long that is.
To avoid expired token errors, I need to call "refreshTokens" before every call, wich is unelegant.
I saw that it has a filed named "expires_in", described here : https://docs.globus.org/api/auth/reference/#token-introspect
however, maybe the SDK provides a way to track expiry.
My other question is interpreting the result of refreshTokens, the response is a list of tokens with status, it seems that "fulfilled" means the refresh was successful :
authorizationManager.refreshTokens().then(res => {
for (let i = 0; i < res; i++) {
if(res[i].status !== "fulfilled") {
setIsAuthenticated(false)
return
}
}
setIsAuthenticated(true)
})
In my case, i treat the existence of a single invalid (or expired) token as "needing to login again".