Hi, if you are using oauth2, you can get rid of the ads.properties file 
altogether.  Use the oauth2 example to generate your refresh token - After 
the line with authorizationFlow.createAndStoreCredential, simply save the 
value of credential.getRefreshToken(). When you run this make sure you put 
your mcc account client/customer id into the ads.properties file. 
Alternatively you can get a refresh token for each adwords account and save 
that, but the using a mcc one saves switching each time.

Once you have a refresh token, you can use the following in your client 
code:

GoogleCredential credential = new 
GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setClientSecrets(CLIENT_ID, CLIENT_SECRET)
            .build();
        // TODO - get this from the db for each account if we don't manage 
them all under the same mcc
        
credential.setRefreshToken(getRefreshTokenForCustomer(ADWORDS_CLIENT_ID);
        AdWordsSession session = new 
AdWordsSession.Builder().withDeveloperToken(ADWORDS_DEV_TOKEN).withUserAgent("UserAgent").withClientCustomerId(ADWORDS_CLIENT_ID).withOAuth2Credential(credential).build();


where the CLIENT_ID and CLIENT_SECRET are from the api console and the 
ADWORDS_CLIENT_ID is the 9ish digit adwords account number and 
ADWORDS_DEV_TOKEN is you developer token for the mcc account.

You can pass any other options in a similar fashion...

Hope that helps

John

On Saturday, 12 January 2013 11:41:44 UTC, Kapil wrote:
>
> Hey Stamatina,
>
> I'm not sure which language you are using, but here is what I'm doing in 
> java.
>
> In ads.properties you can see a section:-
>
> *1.* api.adwords.clientCustomerId=INSERT_CLIENT_CUSTOMER_ID_HERE
>
> You can define one of the client_ids that are connected to your MCC 
> account.
> Now, next time if you want to change the client Id to other ids that are 
> present in MCC account, you can simply do it by creating adwords session 
> and set the id in that session...like this:-
>
> String clientLoginToken = new 
> ClientLoginTokens.Builder().forApi(ClientLoginTokens.Api.ADWORDS).fromFile().build().requestToken();
>           AdWordsSession session = new 
> AdWordsSession.Builder().fromFile().withClientLoginToken(clientLoginToken).build();
>
> session.setClientCustomerId(clientCustomerId)
>
>            AdWordsServices adWordsServices = new AdWordsServices();
>
> *2.* You can also use OAuth 2.0 for that. You don't have to refresh it 
> all the time.
>
> In ads.properties set the refresh oauth token true
>
> api.adwords.refreshOAuth2Token=true
>
> *3.* I'm not sure on this one but I think you have to link the new client Id 
> with your MCC account. 
>
>
> *4.* If you want to refresh the authentications manually then I guess after 
> every 60 minutes you have to refresh the credentials.
>
>
> 5. I'm also facing this issue regarding storing the credential in the 
> database so that I can access it and refresh the same credential again and 
> again.
>
>
> I hope this helps.
>
>
> Thanks,
>
>
> Kapil
>
>
> On Friday, January 11, 2013 8:39:08 PM UTC+5:30, Stamatina Thomaidou wrote:
>>
>> Hello everyone,
>>
>> this is a more general question regarding the new ways that we have to 
>> work with authentication and access to the accounts.
>>
>> We have a developer token for the AdWords API that actually corresponds 
>> to an MCC Account. We have already some client/customer accounts that are 
>> already linked through the AdWords Interface and Tab "Link Existing 
>> Accounts" and let's say that we want to modify their campaigns etc. Do we 
>> have to use an ads.properties file for each one of them? Is there any other 
>> way? Or do we have to access them programmatically using OAuth 2.0 with 
>> temporary access tokens that each time we have to refresh them?
>> Now imagine that we want to have access to totally new clients/customers 
>> that are not yet linked to the MCC Account. Can we have access to them only 
>> through OAuth 2.0 and how? Or is it mandatory to go to the AdWords 
>> interface and Tab "Link Existing Accounts" and define explicitly there that 
>> we want to administrate and have access to them through the API?
>>
>> Is there any documentation/tutorial inside this webpage that I may have 
>> not seen? I think that is a good idea to explain further all these concepts 
>> with some example scenarios.
>>
>> Next, a more focused question. The credential received from the OAuth 2.0 
>> authentication is a temporary one. Thus, how much often do we have to 
>> refresh it? How can we store the credential info inside let's say a 
>> database field? (Due to the credential object does not correspond to an 
>> understandable form for let's say a mysql database field).
>>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.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



Reply via email to