I have setup the glass-java-starter project and encounter an issue in notification flow, which is handled by NotifyServlet.
I can't get the "credential" occasionally。
Below is the where I encounter the problem.
Credential credential = AuthUtil.getCredential(userId);
credential will be null after this line occasionally even I didn't restart the server
Once I got error, I can solve it by re-login to the website.
I am not sure whether there is a timeout for the "Credential" store, and if yes, how long is it, and how to handle the timeout, any practice to follow?
Further Update:
Some finding:
I found we can get the expiry time from Credential object as below
credential.getExpiresInSeconds()
I can get a return value which is around 3600, right after I get the credential. So I think usually the expiry time of access token is 1 hr.
When I encounter the problem, I believe it just couple mins after I logged in, won't be longer than one hour.
Another point is, if the problem is about credential timeout, then I believe I can still get the credential object by following code, even the token stored in it is invalid, the credential object should be there.
Credential credential = AuthUtil.getCredential(userId);
So I suspect the problem is in credential object store, I am not sure how current app store the credential, but even it is in memory, I think I should be able to get it as long as I don't restart the server. So don't know whey I encounter the "Null" return here