renewedtoken = createToken(getAppId(),getServiceName()); // Now create a new token and save that in the store
Context context = Context.get();
setAccessTokenObject(renewedtoken);
try {
if(!context.isCurrentUserAnonymous()) {
CredentialStore credStore = findCredentialStore();
if (credStore != null) {
// if the token is already present, and was expired due to which we have fetched a new
// token, then we remove the token from the store first and then add this new token.
deleteToken();
credStore.store(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId(), token);
}
} else {
AnonymousCredentialStore.storeCredentials(context, token, getAppId(), getServiceName()); // Store the token for anonymous user
}
} catch (CredentialStoreException cse) {