googleads / googleads-python-lib

The Python client library for Google's Ads APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to check if the service account is connected/invited to the someone else Google Ads?

dendihandian opened this issue · comments

I have this code:

from googleads import ad_manager
from googleads import oauth2

oauth2_client           = oauth2.GoogleServiceAccountClient('./path-to-the-service-account-file.json', oauth2.GetAPIScope('ad_manager'))
ad_manager_client   = ad_manager.AdManagerClient(oauth2_client=oauth2_client, application_name='my_application_name')

when I list the networks with this, it returns empty list:

    networks = ad_manager_client.GetService('NetworkService').getAllNetworks()
    for network in networks:
        print('Network with network code "%s" and display name "%s" was found.' % (network['networkCode'], network['displayName']))

I'm pretty sure the my service account email is already connected/invited to the google ads manager. How to find out if it's connected in programmatically?

The method you're calling is the correct way to determine access programmatically. Note that service accounts must be added directly in the network settings page, not invited:
https://support.google.com/admanager/answer/6078734?

You can check the network's users in the UI and filter on "Service account" to determine if the service account was directly added.