We currently have a batch job that refreshes the access token using the refresh token every 50 minutes or so.
This is how we currently construct the GoogleCredentials
object to construct the gmail api.
Credential cred = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setClientSecrets(clientId, clientSecret)
.build()
.setAccessToken(accessToken)
.setRefreshToken(refreshToken);
return new Gmail.Builder(httpTransport, jsonFactory, cred).setApplicationName("SalesforceIQ").build();
I don't see any advantage of setting the refreshToken
in the GoogleCredentials
. I am able to successfully authorize myself and return correct responses with just the access token.
Is the advantage of setting the refresh token that the accessToken is refreshed by google when invalid (during an API request)? If so, is there a way of getting this new access token back from google (so that we can store it in our db)?