oauth2 service account with google adwords api for ruby

774 views
Skip to first unread message

Antony Vorobiev

unread,
Aug 14, 2012, 11:07:08 AM8/14/12
to adwor...@googlegroups.com
Hello all,

I was using ClientLogin authorization method in my server application for several months, but now it throws CaptchaRequired error because of too much authorization attempts for about 100 client_customer_id in a batch, so I'm looking for the way to get 100+ client accounts processed (sync campaigns, fetch campaign statuses, report statistics) in reasonable time (several minutes) without any user interaction

according to - https://developers.google.com/accounts/docs/OAuth2 - this document, the most suitable method for me is OAuth 2.0 Service Account authorization

I've got all the credentials - Client ID, Email address, Application name and private key file, but I still have no idea how can I get this stuff working.


Could you please provide me with an example of how can I access to Adwords API via OAuth 2.0 Service Account and fetch, for example, account hierarchy using Ruby Adwords API library?

Danial Klimkin

unread,
Aug 17, 2012, 5:46:08 AM8/17/12
to adwor...@googlegroups.com
Hi Antony,


We have the AdWords Ruby Client Library available which already has the OAuth2.0 support. There is also a demo application based on Rails that demonstrates the flow (and account hierarchy retrieval as well).

Please check out the library here:


And the demo application here:



Please feel free to ask any related questions as I am the author of both.


-Danial, AdWords API Team.

Marcin Urbanski

unread,
Oct 8, 2012, 9:58:10 AM10/8/12
to adwor...@googlegroups.com
Any update on this? I have exactly the same problem.
If Ruby gems won't support it soon, I can use Java.

Are there any examples on how to use Service to Service authentication?

Sophornia Bartee

unread,
Oct 9, 2012, 2:21:49 AM10/9/12
to adwor...@googlegroups.com

Sophornia Bartee

unread,
Oct 9, 2012, 2:23:26 AM10/9/12
to adwor...@googlegroups.com

Sophornia Bartee

unread,
Oct 9, 2012, 2:26:36 AM10/9/12
to adwor...@googlegroups.com

On Tuesday, August 14, 2012 8:07:08 AM UTC-7, Antony Vorobiev wrote:

Danial Klimkin

unread,
Oct 9, 2012, 5:45:41 AM10/9/12
to adwor...@googlegroups.com
Hello Marcin,


Please see my reply to the initial post which should cover the issue. I've also created an article with more details specific to Ruby:


Let me know if you have any questions.


-Danial, AdWords API Team.

Fredrik Gustafsson

unread,
Oct 9, 2012, 5:49:54 AM10/9/12
to danial.kli...@google.com, adwor...@googlegroups.com
Kinda off topic but just some questions regarding this limit, is it
100 authorizations independent during a certain time limit or am I
missunderstanding? Since you are writing about something about batch.
I am about to launch a platform that will have this amount of users at
the same time.

Regards Fred

2012/10/9 Danial Klimkin <danial.kli...@google.com>:
> --
> =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
> 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 adwor...@googlegroups.com
> To unsubscribe from this group, send email to
> adwords-api...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/adwords-api?hl=en



--

//
MVH / Regards

Fredrik Gustafsson
070-2833674

Danial Klimkin

unread,
Oct 9, 2012, 5:52:32 AM10/9/12
to adwor...@googlegroups.com, danial.kli...@google.com
Hello kes0,


This is defined by the Google Accounts authorization policies which is external to the AdWords API. We are not able to share any details on what triggers captcha challenge.

Please note if you are about to launch a new platform, you should consider implementing OAuth2.0 as soon as possible, as the client login protocol is deprecated and will be removed in the future.


-Danial, AdWords API Team.

Marcin Urbanski

unread,
Oct 9, 2012, 9:05:07 AM10/9/12
to adwor...@googlegroups.com
Thanks for your reply!

The problem is that all code samples are relying on user activity.
What I want to acheive is downloading reports for all managed clients using OAuth Service to Service authentication.
This process should be asynchronous and I believe I need something like this to athenticate:

GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
            .setServiceAccountScopes(STORAGE_SCOPE)
            .setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
            .build();


When will this be possible in pure Ruby? (without need to use Java libraries).


Here's my unanswered post with more details:


Could you help me somehow?

Martin

Radhames Brito

unread,
Oct 9, 2012, 9:06:45 AM10/9/12
to adwor...@googlegroups.com, danial.kli...@google.com
Hello Danial, im using OAuth2 to get data from thou to my platform, what is the preferred process to get it without user interaction with a MCC account? Is there a way too pull reports for each child account using only the MCC credentials (or some sort of master key)? all my child accounts are managed and created with the MCC account so it doesnt make much sense to me to need to log in and grant access to the application for every child accounts (thousands).

Danial Klimkin

unread,
Oct 10, 2012, 8:28:17 AM10/10/12
to adwor...@googlegroups.com
Hello Martin,


I can see you have already logged this request on the project issue tracker, thank you.

I will check if this is possible and let you know. It largely depends on the underlying libraries support for JWT.


-Danial, AdWords API Team.

Danial Klimkin

unread,
Oct 10, 2012, 8:30:27 AM10/10/12
to adwor...@googlegroups.com, danial.kli...@google.com
Hello Radhames,


Yes, it is recommended to use the MCC credentials to access every sub-account. Just specify MCC credentials and sub-account's clientCustomerId.

We also have an example on parallel reports request for this case:



-Danial, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages