Authentication Service Account API AccessTokenRefreshError

255 views
Skip to first unread message

tecno...@t2omedia.es

unread,
Jun 11, 2015, 1:59:57 PM6/11/15
to adwor...@googlegroups.com
Hi, I´m trying to authetica in Google Adwords API but I recive an error:

"oauth2client.client.AccessTokenRefreshError: access_denied: Requested client not authorized."

This is my code:


p12_file = os.getcwd() + '**************.pem'
service_account_email = '*********@developer.gserviceaccount.com'
impersonation_user_email = '******@*****.es'
with open(p12_file, "rb") as f:
private_key = f.read()

self.auth_adwords = oauth2.GoogleServiceAccountClient(oauth2.GetAPIScope('adwords'), service_account_email, p12_file, sub=impersonation_user_email)


The error is in the last line. I need to change the .p12 key because if I use .p12 raise an error about the key and I read about the problems is PyCripto (the library used by googleads) have a problem with p12 keys.
I created the project in console.developer.google.com, and create a service account. I go to my Google for work panel and autorize de client id with the google adwords scope and the impersonation_user_mail have permissions for the entire MCC.
Someone can help me?
Thanks a lot!

Anash P. Oommen (AdWords API Team)

unread,
Jun 11, 2015, 4:45:23 PM6/11/15
to adwor...@googlegroups.com, tecno...@t2omedia.es
Hi,

What scope are you using when authorizing the impersonation email on the Google Apps dashboard? The API scopes changed a while back, that might be the issue. See https://developers.google.com/adwords/api/docs/guides/authentication#scope for details.

Cheers,
Anash P. Oommen
AdWords API Advisor.

tecno...@t2omedia.es

unread,
Jun 12, 2015, 4:22:32 AM6/12/15
to adwor...@googlegroups.com, tecno...@t2omedia.es
Hi Anash, thanks for your response, I use:

https://adwords.google.com/api/adwords/

The same that you say.
Thanks!

Anash P. Oommen (AdWords API Team)

unread,
Jun 12, 2015, 3:05:47 PM6/12/15
to adwor...@googlegroups.com, tecno...@t2omedia.es
That's the old scope, see if https://www.googleapis.com/auth/adwords works for you?

Cheers,
Anash

tecno...@t2omedia.es

unread,
Jun 15, 2015, 4:26:41 AM6/15/15
to adwor...@googlegroups.com, tecno...@t2omedia.es
Yes! This is the problem, but in the spanish documentation are the old scope!


Thanks a lot!!

Anash P. Oommen (AdWords API Team)

unread,
Jun 16, 2015, 12:28:21 PM6/16/15
to adwor...@googlegroups.com, tecno...@t2omedia.es
Hi,

I'll ask our tech writer to resubmit the docs for translation. Thanks for pointing this out.

Cheers,
Anash
Reply all
Reply to author
Forward
0 new messages