Hi Joseph,
Thanks for the response!
We persist refresh and access tokens in to DB and we are using .setCredentialStore() to pass them to Google for auth process.
I realized that access token gets refreshed automatically if I pass expired access token. So I modified my code to capture the new access token and use it for further calls. The blow code really works well. But the only thing is, .setCredentialStore() is deprecated in the current release. I did some research to replace it with latest code. no success. Could you pass me an alternate code snippet that could replace the below code.
Given the nature of our environment, we don't want to store the tokens in file store.
flow = new GoogleAuthorizationCodeFlow.Builder(TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setCredentialStore(new CredentialStore() {
public void store(String arg0, Credential credential) throws IOException {
//Reset the access token with this new access token and use it for further calls
moCredentialObjectFromDB.setAccessToken(credential.getAccessToken());
}
public boolean load(String arg0, Credential credential) throws IOException {
credential.setAccessToken(moCredentialObjectFromDB.getAccessToken());
credential.setRefreshToken(moCredentialObjectFromDB.getRefreshToken());
return true;
}
public void delete(String arg0, Credential arg1) throws IOException {
}
}).build();
Thanks!
Kumaran Sivapunniyam
Mediaocean