Hi!
I need an offline access to AdWords API. 
I've obtained a refresh token with the help of GoogleAuthorizationCodeFlow 
with 'offline' access type as described here: 
https://code.google.com/p/google-api-java-client/wiki/OAuth2#Authorization_Code_Flow
.
I'm saving the refreshToken in a DB for future use.
With the refresh token I'm able to get a credential with this statement:

Credential credential = new OfflineCredentials.Builder()
                .forApi(OfflineCredentials.Api.ADWORDS)
                .fromFile()
                .withRefreshToken(specificRefresToken)
                .build()
                .generateCredential()

The problem I'm facing is that the credential expires after 1 hour. 
In the documentation it states ' By default, our client libraries 
automatically refresh an expired access token.'  Which utility do I need to 
use to get this functionality?
To play fair, after the credential is initialized I'm putting it into a 
pool so for the next AdWords API request I can reuse it.
So my getCredential method looks like that (is this additional check for 
expiration time required?):

        Credential credential = initializedCredentials.get(client.id)
        if (credential != null && credential.expiresInSeconds > 50) {
            return credential
        }
       //initialize credential and put into initializedCredentials for 
future use
       ....

I wouldn't like to reinvent a wheel if there are some utilities already 
available and  can handle this for me.
I appreciate the feedback.

Cheers!

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.

Reply via email to