Hello,
i'm facing the same issue
i've generated all the required credentials
`client_id` , `client_secret` from a google cloud project
`developer_token` from a production manager account that is linked to the
google account `[email protected]`
`customer_id` from a test client account that is linked to a test manager
account that is linked to the google account `[email protected]`
`login-customer-id` from the test manager account
i'm using the `google-ads` python client library and making the request and
here my code
```
class ListCampaignsView(APIView):
def __init__(self):
self.token = Token.objects.first()
self.customer_id = os.getenv('GOOGLE_ADS_CUSTOMER_ID')
def get(self, request, *args, **kwargs):
customer_id = request.GET.get('customer_id')
credentials = {
"developer_token": os.getenv('GOOGLE_ADS_DEVELOPER_TOKEN'),
"refresh_token": self.token.token,
"client_id": os.getenv('GOOGLE_ADS_CLIENT_ID'),
"client_secret": os.getenv('GOOGLE_ADS_CLIENT_SECRET'),
"use_proto_plus": True,
"token_uri": os.getenv('GOOGLE_ADS_TOKEN_URI'),
"login-customer-id":"1860217890",
}
client = GoogleAdsClient.load_from_dict(credentials,version="v18")
ga_service = client.get_service("GoogleAdsService")
query = """
SELECT
campaign.id,
campaign.name
FROM campaign
ORDER BY campaign.id"""
stream = ga_service.search_stream(customer_id=customer_id,
query=query)
campaigns = []
for batch in stream:
for row in batch.results:
campaigns.append({
"id": row.campaign.id,
"name": row.campaign.name
})
return Response({
"total_campaigns": len(campaigns),
"campaigns": campaigns
})
```
what i'm missing here?
where should i put `login-customer-id`?
On Friday, June 17, 2022 at 10:31:34 PM UTC+2 Google Ads API Forum Advisor
wrote:
> Hi Ajit,
>
> Thank you for reaching out to the Google Ads API support team.
>
>
> 1. I want to understand what is the difference between login customer id
> and client customer id?
> The login-customer-id
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid>
> is
> a new required header in Google Ads API when using a manager account to
> access an operating customer account. If accessing an operating customer
> account directly, the login-customer-id header is not required. Please
> see this guid
> <https://developers.google.com/google-ads/api/docs/migration/login-customer-id?hl=en>e.
>
> Client customer id is child account of manger account.
>
>
> 2. How do I get login customer id and client customer id ?
> You may refer to this guide
> <https://developers.google.com/google-ads/api/docs/first-call/overview?hl=en>
> .
>
>
> 3. When do I have to use both login customer id and client customer id
> while making API call?
> You may refer to this guide
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure?hl=en>
> .
>
> Moving forward to your concern, it seems that you've encountered the
> USER_PERMISSION_DENIED error. The authorized customer does not have access
> to the operating customer. The common cause of this is when authenticating
> as a user with access to a manager account but not specifying
> login-customer-id in the request. To prevent this kind of error, I would
> suggest specifying the login-customer-id as the manager account ID without
> hyphens (-). That being said, you will need to ensure that the user / email
> address you used to generate the credentials indeed has access
> <https://support.google.com/google-ads/answer/9978556?visit_id=637628826037447236-382779227&rd=1>
> to
> the account in your request. If the user / email address has access or is
> associated with the MCC / manager account, you will need to specify the MCC
> / manager account's ID without hyphens (-) as the value of the
> login-customer-id
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid>
> field.
> If the issue still persistsTo investigate the issue further, could you
> please provide the complete request
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
> and response
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
> logs,
> with the request-id
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
> generated
> on your end along with the email address used to generate the OAuth2
> credentials, so that our team will investigate this problem. Please reply
> via privately autor option.
>
>
> Thanks,
> [image: Google Logo]
> Nirmitabahen Gaurav
> Google Ads API Team
>
>
>
> Thanks,
>
> ref:_00D1U1174p._5004Q2bxKrH:ref
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/adwords-api/0ebbe791-c9e1-4a80-8514-e77f7a08c8f5n%40googlegroups.com.