Hi Chris,

If your MCC (My Client Center) account has access to the client accounts 
then you can simply generate a refresh token for the MCC using one of the 
"offline credentials" examples (e.g., the Java 
example<https://code.google.com/p/google-api-ads-java/source/browse/examples/adwords_axis/src/main/java/adwords/axis/auth/GetRefreshToken.java>).
 
 The example will provide you with a URL where you will accept the OAuth2 
request for the client ID & secret.  When navigating to this URL make sure 
that you are logged in to your MCC account.  You will only have to do this *
once* and you will want to store the refresh token in your database.

Once you have a refresh token for your MCC, you can establish an AdWords 
session as follows (the areas to update with your values are in *bold*):

    Credential oAuth2Credential = new OfflineCredentials.Builder()
        .forApi(Api.ADWORDS)
        .withClientSecrets("*YOUR_CLIENT_ID*", "*YOUR_CLIENT_SECRET*")
        .withRefreshToken("*YOUR_REFRESH_TOKEN*")
        .build()
        .generateCredential();

    AdWordsSession session = new AdWordsSession.Builder()
        .withDeveloperToken("*YOUR_DEVELOPER_TOKEN*")
        // Optional - set customer ID or use session.setClientCustomerId 
prior to API requests
        .withClientCustomerId("*OPTIONAL**_CLIENT_CUSTOMER_ID*")
        // Optional - specify a string to use for identifying requests from 
your app
        .withUserAgent("*OPTIONAL_STRING_FOR_IDENTIFYING_REQUESTS*")
        .withOAuth2Credential(oAuth2Credential)
        .build();

If you want to make requests for different client customer IDs then you can 
simply call session.setClientCustomerId("YOUR_NEXT_CUSTOMER_ID") before the 
next API call.  This will all work as expected as long as the MCC is linked 
to each of the client customer IDs.

Best,
Josh, AdWords API Team

On Sunday, October 27, 2013 5:40:16 PM UTC-4, [email protected] wrote:
>
> Are there any examples of using oauth2 with the following:
>
>    - credentials stored in a database and not in a properties file
>    - client center credentials used to access an account within a client 
>    center
>    - batch job so no interaction with an end user
>
> thanks,
>
> Chris Marshall
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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/groups/opt_out.

Reply via email to