Hey Google Ads team,

I'm working on behalf of a client. The client has a regular ads account, 
and a manager account that owns the regular ads account.


The client invited me with ade...@ibenjamen.com to the project. We applied 
for the developer token, and we have basic access. I went through the 
process that I describe here of generating the refresh token; 

https://www.loom.com/share/32ae63f386b44481a625264657d9a3b6

Below is the code of what we are trying to do simply uploading google click 
conversions through the api.

In essence we have an airtable app, where we can click a button and it will 
send it to google ads. It worked with the test accounts and test tokens, 
but now it does not. We only intend to use it internally. 

When running it after we got approved for the basic access token we get 
this error:


" 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. See 
https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid"";
How do I fix the permission thing?



Here is the code of sending the click conversions (straight from the python 
client)
For context, this code runs in a google cloud function. That I created on 
behalf of customer.
import functions_framework
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
import os

@functions_framework.http
def upload_conversion(request):
# Set CORS headers for preflight requests
if request.method == 'OPTIONS':
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '3600',
'Access-Control-Allow-Credentials': 'true',
}

return ('', 204, headers)

# Set CORS headers for the main request
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true',
}

if request.method != 'POST':
return ('Method not supported', 405, headers)

request_json = request.get_json(silent=True)

if request_json and 'customer_id' in request_json:
customer_id = request_json['customer_id']
conversion_action_id = request_json['conversion_action_id']
gclid = request_json.get('gclid', None)
conversion_date_time = request_json['conversion_date_time']
gbraid = request_json.get('gbraid', None)
wbraid = request_json.get('wbraid', None)
else:
return ('Invalid BRO request', 400, headers)

if not gclid and not wbraid and not gbraid:
return ('No gclid or wbraid present', 400, headers)

cwd = os.getcwd()
config_file_path = os.path.join(cwd, 'google-ads.yaml')

client = GoogleAdsClient.load_from_storage(path=config_file_path, version=
'v14')

click_conversion = client.get_type("ClickConversion")
conversion_upload_service = client.get_service("ConversionUploadService")
conversion_action_service = client.get_service("ConversionActionService")
click_conversion.conversion_action = 
conversion_action_service.conversion_action_path(
customer_id, conversion_action_id
)

if gclid:
click_conversion.gclid = gclid
elif gbraid:
click_conversion.gbraid = gbraid
else:
click_conversion.wbraid = wbraid

click_conversion.conversion_date_time = conversion_date_time

request = client.get_type("UploadClickConversionsRequest")
request.customer_id = customer_id
request.conversions.append(click_conversion)
request.partial_failure = True
conversion_upload_response = 
conversion_upload_service.upload_click_conversions(
request=request,
)

if conversion_upload_response.partial_failure_error:
return (conversion_upload_response.partial_failure_error.message, 400, 
headers)

uploaded_click_conversion = conversion_upload_response.results[0]

print(
f"Uploaded conversion that occurred at "
f'"{uploaded_click_conversion.conversion_date_time}" from '
f'Google Click ID "{uploaded_click_conversion.gclid}" '
f'to "{uploaded_click_conversion.conversion_action}"'
)

return ('Conversion uploaded', 200, headers)


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d62fc28d-938a-4fcd-be7d-b82733081178n%40googlegroups.com.

Reply via email to