Reputation: 25
I am using box.com Java SDK for V2 API. I notice from time to time that the refresh of tokens fail even though it has not been more than 14 days since the refresh_token was obtained. The reason behind why it failed is not surfaced up to the caller.
What do you suggest are the best practices for retrying to refresh the tokens?
Upvotes: 0
Views: 424
Reputation: 331
When the token get refreshed, the old refresh token and access token is expired. You'll want to add a OAuthRefreshListener to monitor the refresh events.
client.addOAuthRefreshListener(new OAuthRefreshListener() {
@Override
public void onRefresh(IAuthData newAuthData) {
// TODO: your logic to save the new auth data.
}
});
After you exit the application and reenter, you can use the saved auth data to authenticate the client.
Upvotes: 0