Hi Ian,

Service accounts are quite complex -- as mentioned in our OAuth2.0 Service 
Accounts guide 
<https://developers.google.com/adwords/api/docs/guides/service-accounts#alt>
:

> Many developers look at service accounts because they are interested in 
> programmatic access to an API using OAuth2.0, but without user 
> intervention. However, due to the complicated nature of setting up service 
> accounts for the AdWords API, a simpler alternative that achieves the same 
> goal is to use the OAuth 2.0 installed application flow and persist the 
> refresh token. This way, your application will always be able to request a 
> new access token when necessary.


I would definitely recommend trying the *installed application* flow first 
- it works for 99% of the developers I speak to who initially think they 
need a service account.

As far as getting the refresh token for the *installed application* flow 
goes, please check out our OAuth2 wiki 
<https://github.com/googleads/googleads-perl-lib/wiki/Using-OAuth-2.0> on 
github. It'll walk you through the process, step by step.

For you use case, by "Master Account" I'm guessing you mean an MCC (My 
Client Center) account. If all of your AdWords accounts are linked to your 
MCC, similar to the layout described in this guide 
<https://developers.google.com/adwords/api/docs/guides/clientlogin-to-oauth2-single-mcc>,
 
then you can just obtain a single refresh token while logged in as the MCC, 
and then set the *clientCustomerId* on each request in one of two ways:

1. Set the *client *in your adwords.properties file (this probably won't be 
ideal for your use case because you have multiple AdWords accounts).
2. Call set_client_id(xxxx) on your Client 
<https://github.com/googleads/googleads-perl-lib/blob/master/lib/Google/Ads/AdWords/Client.pm>
 object 
between API calls.

Cheers,
Josh, AdWords API Team

On Friday, August 15, 2014 2:47:59 PM UTC-4, Ian wrote:
>
> Hi all,
>
> I've inherited a some code that recently used ClientLogin and needs to 
> work with Oauth2. I've been rummaging through the documentation, like at 
> https://github.com/googleads/googleads-perl-lib/wiki/Using-OAuth-2.0 and 
> using Perl client 2.17 but struggling to understand what I need to set up. 
> Firstly its to be used for a server to automate communication with adwords 
> to check various campaigns etc, so I'm assuming Service Account is what 
> seems applicable.
>
> I'm looking at adwords.properties, and have set up a project at 
> console.developers.google.com (I've also generated a P12 key, converted 
> and uploaded)
>
> I'm a bit confused about several parts. Service Accounts in the 
> documentation seems to imply it needs a oAuth2ClientSecret, however in the 
> console login it only seems to provide Client Id, Email-Address, 
> Fingerprints when I select that. So first question is, is a clientSecret 
> needed for service accounts (and if so, why isn't it displayed, or where do 
> I get it)? 
>
> In Adwords, we have a Master Account with one client id, and then also a 
> client id per domain account. Should I be setting clientId in 
> adwords.properties with the master account clientId, or domain account 
> clientId ?
>
> Currently in adwords.properties I have...
>
> clientId=xxx-xxx-xxxx (master clientId but have tried domain clientId, not 
> sure which is correct)
>
> oAuth2ClientId=10......apps.googleusercontent.com
> oAuth2ServiceAccountEmailAddress=10........@developer.gserviceaccount.com
> oAuth2ServiceAccountDelegateEmail=em...@mydomain.com  (tried master email 
> and domain email)
> oAuth2ServiceAccountPEMFile=/fullpathwheremypemfileis.pem
>
> When I try and run anything it displays ""error_description" : "Invalid 
> impersonation prn email address.". Does it need something from 
> http://www.google.com/enterprise/apps/business/ for example ?
>
>
> Apologies for the long mail, wondering if anyone can help me understand 
> how to get this working, as I'm not finding the process clear. (any 
> examples would be greatly appreciated).
>
> Many thanks,
>
> Ian
>
>
>
>
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to