google ads API authentication failed - "PERMISSION_DENIED"
My question is the same as described here: How to set request header in google ads api but I'm still facing the problem.
I'm trying to make an API call to google ads. I tried Rest API as well as google.ads.google_ads library. Both ways fail. I followed all Oath2 steps and got all ids, tokens, secrets, etc. The Rest API call is :
refresh_token = MY_REFRESH_TOKEN customer_id = 7868****** developer_token = MY_DEVELOPER_TOKEN access_token = MY_ACCESS_TOKEN url = 'https://googleads.googleapis.com/v6/customers/{}/campaignBudgets:mutate'.format(customer_id) headers = {'developer-token':developer_token,"Authorization": "Bearer {}".format(access_token),'login-customer-id':'2693******',"Content-Type": "application/json"} response = requests.post(url,headers = headers) print(response.text)
and this is the response:
{ "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } }
Why? I provided an access token.
I also tried the "google-ads" code I found in the documentation:
https://developers.google.com/google-ads/api/docs/reporting/example
I generated a googleads.ymal file, with the following content:
developer_token: MY_DEVELOPER_TOKEN user_agent: MY_COMPANY_NAME client-id: 7868****** login-customer-id: 2693****** client_id: MY_CLIENT_ID client_secret: MY_CLIENT_SECRET refresh_token: MY_REFRESH_TOKEN
and this is what I get:
Error with message "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header
and again I don't understand why. My user was the one to generate all login details, and it has access to the manager account, which listed as "login-customer-id".
Can anyone shed some light?
Thanks