How to set Login Customer Id and client customer id in google ads api

5,194 views
Skip to first unread message

Ajit Trivedi

unread,
Jun 17, 2022, 4:03:48 AM6/17/22
to Google Ads API and AdWords API Forum
Hi, 
I am getting a USER_PERMISSION_DENIED error while making google ads API call. Upon googling I got to know that we need to pass login customer id and client customer id while making API call?
1. I want to understand what is the difference between login customer id and client customer id?
2. How do I get login customer id and client customer id ?
3. When do I have to use both login customer id and client customer id while making API call?
Some sample code examples to use both login customer id and client customer id using java library would be helpful

Thanks & Regards,
Ajit

pmoe...@binaerpark.de

unread,
Jun 17, 2022, 6:34:40 AM6/17/22
to Google Ads API and AdWords API Forum
Hej Ajit,

you will need:
developerToken -> you find in the manager account
loginCustomerId -> the customer no. of the manager account 

clientId -> you find it in your oauth authentication console
clientSecret -> same here

All this values you have to put in a ini/config file

(client) CUSTOMER_ID -> the customer no. of the account/customer you want to edit
This value you need in your code / api request

Hope  that helps you!

Patrik

Ajit Trivedi

unread,
Jun 17, 2022, 7:09:39 AM6/17/22
to Google Ads API and AdWords API Forum
Hi Patrik,
Thank you very much for clarifying that. 
Also here is "loginCustomerId -> the customer no. of the manager account ", the customer number  my Google manager account or clients Google Manager account. My use case is to export users to the client's Google Ads account.

I am getting USER_PERMISSION_DENIED while making google ads API call to export user to my clients google ads account.
Thanks,
Ajit

Message has been deleted

pmoe...@binaerpark.de

unread,
Jun 17, 2022, 8:34:12 AM6/17/22
to Google Ads API and AdWords API Forum
Did you set the API permission right?
You have to activate the API which you need for your project here:

And if you try to connect you have to set the scopes right.

Ajit Trivedi

unread,
Jun 17, 2022, 11:50:06 AM6/17/22
to Google Ads API and AdWords API Forum
So I obtained permission to export users to my client's google ads account using the OAuth process. So I guess there's no problem there?
Can you please tell me whose manager account Id should i give while making an API call? Shall I give my Google Manager Account id as a Login customer Id or my client's Google Manager account id?

Google Ads API Forum Advisor

unread,
Jun 17, 2022, 4:31:34 PM6/17/22
to ajit.triv...@gmail.com, adwor...@googlegroups.com
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 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 guide. 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.

   
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.

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 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 field. If the issue still persistsTo investigate the issue further, could you please provide the complete request and response logs, with the 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,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 

    

Thanks,

ref:_00D1U1174p._5004Q2bxKrH:ref

tarik waleed

unread,
Nov 27, 2024, 2:46:21 PM11/27/24
to Google Ads API and AdWords API Forum
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 `a...@gmail.com`
`customer_id` from a test client account that is linked to a test manager account that is linked to the google account `x...@gmail.com`
`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`?

Google Ads API Forum Advisor

unread,
Nov 28, 2024, 12:54:42 AM11/28/24
to tarikwal...@gmail.com, adwor...@googlegroups.com
Hi,

I would like to inform you that the login-customer-id is a new required header in the 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. If the user/email address has access to 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 field.

In order to identify the reason why you're encountering the error USER_PERMISSION_DENIED error, please share the complete API logs (requestresponserequest-id and request header) generated on your device with us.  

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. You can enable logging via the curl command by using the -i flag for REST interface requests.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02bxKrH:ref" (ADR-00111335)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5


 


Reply all
Reply to author
Forward
0 new messages