'invalid_grant: Bad Request' for AdwordsUserListService mutate call ...

63 views
Skip to first unread message

t...@v1.com.au

unread,
Feb 12, 2019, 3:03:13 AM2/12/19
to AdWords API and Google Ads API Forum
I have read through the variety of "invalid_grant" questions on this board, but unfortunately didn't find anything that helped resolve my particular issue.

I am trying to get the samples working with the following config in my googleads.yaml:

  # This token has been approved and has Access level "Basic Access"
  developer_token: "<token from Tools/API Center/API Access/Developer token on the MCC account>"

  # We are only interested in automating tasks to our single ad account. The MCC with our developer token manages that account.
  client_customer_id: "<the ID for the single ad account managed by the MCC account>"

  #############################################################################
  # The following values configure the client for the installed application
  # flow.

  # The account I use to manage the credentials is not the same as the one with the MCC account, is this significant? 
  # (I did try creating the credentials on the MCC account and had the same issue, so I think not).
  client_id: "<Client ID from the credentials section on console.developers.google.com (type Other)>"
  client_secret: "<Again from the console.developers.google.com credentials entry>"

  # When I generated this token I authenticated as the MCC account (which has access to the managed google ads account -> client_customer_id above).
  refresh_token: "<Token generated using the generate_refresh_token.py tool (using the credentials above>"

When I check https://myaccount.google.com/permissions I can see the details specified in the "OAuth consent screen" as having access to "Manage your AdWords campaigns".

When I use:

-d refresh_token=<refresh token above> \
-d client_id=<client id above> \
-d client_secret=<client secret above> \
-d access_type=offline \
-d grant_type=refresh_token

I get back:

{
  "access_token": "<new access token>",
  "expires_in": 3600,
  "token_type": "Bearer"
}

Which seems healthy.

When I run the sample code from here -> https://developers.google.com/adwords/api/docs/samples/python/remarketing "Create and populate a user list"

It fails on this line (presumably the first time it tries to authenticate):

result = user_list_service.mutate(operations)

with:

google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', '{\n  "error": "invalid_grant",\n  "error_description": "Bad Request"\n}')

I have tried regenerating a refresh tokens (authenticated on other accounts who have access to the ad account I need to manage) with little success.

I have noticed on similar questions you have asked for a private reply with account details to investigate further and I would be happy to do that.

Thanks.



googleadsapi...@google.com

unread,
Feb 12, 2019, 5:35:33 AM2/12/19
to adwor...@googlegroups.com
Hi Tom,

The usual reason for having the invalid_grant issue is due to an expired refreshToken. However, I would like to recommend that you regenerate all your OAuth2 credentials including the client_id and client_secret and retry your request. Should the issue persist, kindly reply to me privately (via Reply privately to author) the logs along with the email address you used when generating your OAuth2 credentials so I can further investigate.

Thanks and regards,
Peter
AdWords API Team


Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/25881df7-dafb-4a47-8d28-e36d9c6f84b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages