Hi,
I've obtained a refresh tokens with help of GoogleAuthorizationCodeFlow
helper class.
I've stored them in a safe place(db).
Whenever I wan't to access AdWords API I create a Credential in the
following way:
Credential credential = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.fromFile() //clientId and secret is there
.withRefreshToken(specificToken)
.build()
.generateCredential()
Everything works fine but as expected the accessToken expires after an
hour.
To play fair with the API after generation of the credential I'm putting
into a 'pool' with some id associated for future use.
getCredential(Client client) {
def credential = initializedCredentials.get(client.id)
if (credential != null && credential.expiresInSeconds > 50) {
return credential
}
// init credential, put into initializedCredentials and return
}
My question would be if I have to check the expiry time by myself?
In the docs we can find 'By default, our client libraries automatically
refresh an expired access token.'
What pattern, mechanism would I have to use to achieve that?
Or maybe my approach is correct?
Thanks for feedback!
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.