Error Reading From Api V11 - User in the cookie is not a valid Ads user.

479 views
Skip to first unread message

Jose Luis Petracca

unread,
Jul 20, 2022, 2:55:45 PM7/20/22
to Google Ads API and AdWords API Forum
Hi, 

I am trying to get data form the api, it is a really simple request, that is an example from the package

System information:
  • python 3.9.9
  • package version google-ads==17.0.0
  • using service account

The Code


from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException

credentials = {
    "developer_token": "devELOPERTOkeen",
    "json_key_file_path" : PATH_TO_SERVICE_ACCOUNT_JSON,
    "impersonated_email":"serviceacc...@email.iam.gserviceaccount.com",
    "use_proto_plus": True,
    'login_customer_id' : '1111111122' #MMC ID
}
   
googleads_client = GoogleAdsClient.load_from_dict(credentials)


def stream_response(client, customer_id, query):
    return client.get_service("GoogleAdsService").search_stream(customer_id, query=query)

def main(client, customer_id):
    query = "SELECT campaign.name FROM campaign LIMIT 10"
    response = stream_response(client, customer_id, query=query)
    for batch in response:
        print(batch)


customer_id = '1223334445'
main(googleads_client, customer_id)

The Response  /error
GoogleAdsException: (<_SingleThreadedRendezvous of RPC that terminated with:    status = StatusCode.UNAUTHENTICATED    details = "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."    debug_error_string = "{"created":"@1658341926.845702000","description":"Error received from peer ipv6:[2800:3f0:4002:80c::200a]:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}" >, <_SingleThreadedRendezvous of RPC that terminated with:    status = StatusCode.UNAUTHENTICATED    details = "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."    debug_error_string = "{"created":"@1658341926.845702000","description":"Error received from peer ipv6:[2800:3f0:4002:80c::200a]:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}" >, errors { error_code { authentication_error: NOT_ADS_USER } message: "User in the cookie is not a valid Ads user." } request_id: "8ykzEeM7wVjZoJ1VDI54aw" , '8ykzEeM7wVjZoJ1VDI54aw')




Using service account is mandatory. Anyone knows what i am doing wrong?

Regards
Jose Luis

Jose Luis Petracca

unread,
Jul 21, 2022, 1:20:29 PM7/21/22
to Google Ads API and AdWords API Forum
Please dont forget to reply this

Google Ads API Forum Advisor

unread,
Jul 21, 2022, 3:04:13 PM7/21/22
to jlpet...@nwa.digital, adwor...@googlegroups.com
Hi Jose,

Thank you for reaching out to the Google Ads API support team.

It looks like we have a separate thread for this issue and you confirmed on that thread you fixed that error, the solution was reinstall google-ads python package. We can keep correspondence related to this issue on the other thread to limit any confusion.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bm7gu:ref

Jose Luis Petracca

unread,
Jul 21, 2022, 5:58:54 PM7/21/22
to Google Ads API and AdWords API Forum
Sorry, that was an Error, that i've fixed

This is a new one, the detail in this thread is correct

Google Ads API Forum Advisor

unread,
Jul 22, 2022, 12:00:27 AM7/22/22
to jlpet...@nwa.digital, adwor...@googlegroups.com

Hi Jose,


Thank you for getting back to us. I work with Nirmita and allow me to assist you here. I hope you are doing well today.
 

Moving forward, could you please confirm again if your problem is fixed now? I ask this because upon checking the duplicate of this thread you say this "I have fix that error, the solution was reinstall google-ads python package". Also , please use one thread only for better tracking and to avoid confusion


Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bm7gu:ref

Jose Luis Petracca

unread,
Jul 22, 2022, 11:01:45 AM7/22/22
to Google Ads API and AdWords API Forum
No, the problem isnt fix and this is the problem 


=====START HERE ====
==== ENDS HERE ===

Google Ads API Forum Advisor

unread,
Jul 22, 2022, 11:47:06 AM7/22/22
to jlpet...@nwa.digital, adwor...@googlegroups.com

Hi Jose,

Thank you for the reply. Allow me to assist you here.

To further address the issue, I would suggest checking on your end if you already met the Prerequisites mentioned on this document. Also, you can double-check the configuration of your service account based on this guide to address the issue. Lastly, you will need to ensure as well that the user account you used in configuring service account should have access or added to the Google Ads account where you are requesting the API calls.


Best,

Google Logo
Anthony Cyril
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bm7gu:ref

Jose Luis Petracca

unread,
Jul 23, 2022, 12:02:00 AM7/23/22
to Google Ads API and AdWords API Forum
I did all what documentation said.

Also I did the Wide delegation to the service account

Google Ads API Forum Advisor

unread,
Jul 25, 2022, 2:04:18 AM7/25/22
to jlpet...@nwa.digital, adwor...@googlegroups.com
Hi Jose,

Thank you for getting back to us.

Moving forward, to be clear, what we are saying is the user account that you used in configuring your Google Ads API Console project should have access to your target specific account.

Regards,
Google Logo
Carmela
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bm7gu:ref

Jose Luis Petracca

unread,
Jul 25, 2022, 8:59:55 AM7/25/22
to Google Ads API and AdWords API Forum
Yes it has access

Google Ads API Forum Advisor

unread,
Jul 25, 2022, 12:44:18 PM7/25/22
to jlpet...@nwa.digital, adwor...@googlegroups.com
Hi Jose,

Thank you for reaching out to our API support team.

Kindly not that the NOT_ADS_USER error usually occurs when the login used to generate the access token is not associated with any Google Ads account. Make sure to log in with a valid Google Ads account (typically your manager account) for the OAuth flow.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.

Also, could please confirm if you followed all the prerequisites for service accounts? If not, you may refer to this guide to confirm if you already followed every step of the service account, specifically the prerequisites. If the issue persists, please provide us the user account / email address that you've used to set up the service account. We are referring here to the user account / email address for the Google API Console project that has been configured for the Google Ads API. You can provide these details via Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

In addition, we strongly recommend using OAuth2 installed app or web flows instead of service accounts unless you need domain-specific features (for example, impersonation). OAuth2 installed application and web flows require user interaction only once, when access to the account is granted. You need to implement the code set up on your end to make calls using service accounts.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bm7gu:ref
Reply all
Reply to author
Forward
0 new messages