.net adwords api 'Failed to get access token for service account'

460 views
Skip to first unread message

otser...@allthingsweb.gr

unread,
Apr 8, 2014, 11:22:56 AM4/8/14
to adwor...@googlegroups.com
Hi,

i use the new adwords api (v201402) and i have trouble downloading reports via api.
I have successfully completed the entire procedure of service account (https://developers.google.com/adwords/api/docs/guides/service-accounts).
I use this configuration:

    <add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
    <add key="OAuth2ServiceAccountEmail" value="x...@developer.gserviceaccount.com" />
    <add key="OAuth2PrnEmail" value="xxx" />
    <add key="OAuth2JwtCertificatePath" value="path-privatekey.p12" />
    <add key="OAuth2JwtCertificatePassword" value="xxx" />

and i have registered the scope successfully

But sometimes (not always) i get this message : "Failed to get access token for service account" 

Can you help me please?

Message has been deleted

otser...@allthingsweb.gr

unread,
Apr 9, 2014, 7:55:57 AM4/9/14
to adwor...@googlegroups.com
To be specific i get Failed to get access token for service account.\n{\n  \"error\" : \"invalid_request\"\n}"}
But the weird part is that i get  this message after calling the service for about a minute. Until then no errors are shown and i get my reports correctly.

Any ideas?

Τη Τρίτη, 8 Απριλίου 2014 6:22:56 μ.μ. UTC+3, ο χρήστης otser...@allthingsweb.gr έγραψε:
Hi,

i use the new adwords api (v201402) and i have trouble downloading reports via api.
I have successfully completed the entire procedure of service account (https://developers.google.com/adwords/api/docs/guides/service-accounts).
I use this configuration:

    <add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
    <add key="OAuth2ServiceAccountEmail" value="xxx@developer.gserviceaccount.com" />
    <add key="OAuth2PrnEmail" value="xxx" />
    <add key="OAuth2JwtCertificatePath" value="path-privatekey.p12" />
    <add key="OAuth2JwtCertificatePassword" value="xxx" />

Danial Klimkin

unread,
Apr 9, 2014, 8:43:10 AM4/9/14
to adwor...@googlegroups.com
Hello,


Are you running a Google Apps domain? In most cases, you should not be using Service Accounts unless you need very specific features like impersonation.

Please see this guide for more details:



-Danial, AdWords API Team.


On Tuesday, April 8, 2014 7:22:56 PM UTC+4, otser...@allthingsweb.gr wrote:
Hi,

i use the new adwords api (v201402) and i have trouble downloading reports via api.
I have successfully completed the entire procedure of service account (https://developers.google.com/adwords/api/docs/guides/service-accounts).
I use this configuration:

    <add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
    <add key="OAuth2ServiceAccountEmail" value="xxx@developer.gserviceaccount.com" />
    <add key="OAuth2PrnEmail" value="xxx" />
    <add key="OAuth2JwtCertificatePath" value="path-privatekey.p12" />
    <add key="OAuth2JwtCertificatePassword" value="xxx" />

otser...@allthingsweb.gr

unread,
Apr 9, 2014, 9:12:06 AM4/9/14
to adwor...@googlegroups.com
Thanks for the reply.

Yes i am running a Google Apps domain. I implemented each step of the procedure correctly i guess as i get some results back. But sometimes i get  Failed to get access token for service account.\n{\n  \"error\" : \"invalid_request\"\n}"}

Do i miss something?

Otherwise is there a way to use the api with <add key="OAuth2Mode" value="APPLICATION" /> without user interaction?


Τη Τετάρτη, 9 Απριλίου 2014 3:43:10 μ.μ. UTC+3, ο χρήστης Danial Klimkin έγραψε:
Hello,


Are you running a Google Apps domain? In most cases, you should not be using Service Accounts unless you need very specific features like impersonation.

Please see this guide for more details:



-Danial, AdWords API Team.


On Tuesday, April 8, 2014 7:22:56 PM UTC+4, otser...@allthingsweb.gr wrote:
Hi,

i use the new adwords api (v201402) and i have trouble downloading reports via api.
I have successfully completed the entire procedure of service account (https://developers.google.com/adwords/api/docs/guides/service-accounts).
I use this configuration:

    <add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
    <add key="OAuth2ServiceAccountEmail" value="x...@developer.gserviceaccount.com" />
    <add key="OAuth2PrnEmail" value="xxx" />
    <add key="OAuth2JwtCertificatePath" value="path-privatekey.p12" />
    <add key="OAuth2JwtCertificatePassword" value="xxx" />

DavM

unread,
Apr 9, 2014, 9:23:20 AM4/9/14
to adwor...@googlegroups.com
I'm having the same problem with Failed to get access token for service account.\n{\n  \"error\" : \"invalid_request\"\n}"}

I'm using the .net client library. It seems that after retrying several times (more than 5 attempts) it eventually works which is quite unusual.

Danial Klimkin

unread,
Apr 10, 2014, 7:54:56 AM4/10/14
to adwor...@googlegroups.com
Hello,


We recommend to either use "Installed application" or "Web application" flows. The former one for the cases when you manage only your accounts (all accounts are linked to a single MCC) and the latter when you manage unlinked 3rd party accounts.

In both cases, user interaction is only required once (per user), to grant the access. Once access is granted you receive a refresh token you can use indefinitely with no further user input required.


-Danial, AdWords API Team.

otser...@allthingsweb.gr

unread,
Apr 10, 2014, 8:47:20 AM4/10/14
to adwor...@googlegroups.com
Hello,

My problem is that i use the adwords api on various scheduled tasks that user interaction is not possible.
Can you describe me or redirect me to a link that shows clearly how to use adwords api with no user interaction? Is this even possible?

Thanks

Danial Klimkin

unread,
Apr 10, 2014, 9:12:42 AM4/10/14
to adwor...@googlegroups.com
Hello,


As mentioned above, user interaction is required only once, user needs to indicate he / she agrees the account will be managed by your application.

When this is done you receive a refresh token which can be used in your scheduled tasks with no additional user interaction required. Please see:



-Danial, AdWords API Team.

DavM

unread,
Apr 11, 2014, 9:57:36 AM4/11/14
to adwor...@googlegroups.com
Hi Danial

I've managed to eradicate 'Failed to get access token for service account.{  "error" : "invalid_request"}"}' for now by sharing the "AdWordsUser" object between all threads in my application.

Does that mean the error can relate to throttling?

Cheers

David

Danial Klimkin

unread,
Apr 14, 2014, 7:17:23 AM4/14/14
to adwor...@googlegroups.com
Hello David,


There is definitely a limit on how often you can request a new refresh / access tokens. It's recommended to re-share them between threads / services.


-Danial, AdWords API Team.

Senthil Palaniswami

unread,
Aug 20, 2015, 4:10:51 PM8/20/15
to AdWords API Forum
David,

I am using the V201506 API in C# .Net Application by Service Account. I use Service Account Email & .P12 Key file to access this, but i get the below error. Could you please assist ? Thanks

Failed to get access token for service account.

{

  "error" : "unauthorized_client",

  "error_description" : "Unauthorized client or scope in request."

}



Thanks
Senthil

Danial Klimkin

unread,
Aug 21, 2015, 10:52:01 AM8/21/15
to AdWords API Forum
Hello Senthil,


This is a year old non-related thread. Please start a new one instead of resurrecting this old one.


-Danial, AdWords API Team.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages