Load_From_dict error

121 views
Skip to first unread message

vicky vivek

unread,
May 2, 2022, 4:18:33 PM5/2/22
to Google Ads API and AdWords API Forum
I am working on migrating from adwrods api to Google ads api:

I have this chunk in my code:
     for client_account in client_accounts:
            client_id = client_account.master_account.client_id
            client_secret = client_account.master_account.client_secret
            refresh_token = client_account.master_account.refresh_token
            client_customer_id = client_account.customer_id
            owner_key = client_account.owner_key
            trading_platform_name = client_account.master_account.trading_platform_name
            report_logger.debug(client_account.master_account)
            report_logger.debug(client_account)

            credentials = {
                "developer_token":developer_token,
                "refresh_token":refresh_token,
                "client_id":client_id,
                "client_secret":client_secret,
                "login_customer_id":client_customer_id,
                "use_proto_plus":True
             }

        #   credentials.refresh(Request())
            google_ads_client = GoogleAdsClient.load_from_dict(credentials,version="v10")
            print(google_ads_client)

Whenever I execute my python file, I run into this error:
2022-05-02 13:02:25,933 - googleads_campaigns - INFO - Running googleads_campaign_final.py on DEV environment.
2022-05-02 13:02:25,934 - googleads_campaigns - INFO - Initializing database setup.
2022-05-02 13:02:26,300 - googleads_campaigns - ERROR - ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
Traceback (most recent call last):
  File "googleads_campaign_final.py", line 81, in main
    google_ads_client = GoogleAdsClient.load_from_dict(credentials,version="v10")
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/ads/googleads/client.py", line 270, in load_from_dict
    kwargs = cls._get_client_kwargs(config_data)
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/ads/googleads/client.py", line 184, in _get_client_kwargs
    "credentials": oauth2.get_credentials(config_data),
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/ads/googleads/oauth2.py", line 117, in get_credentials
    http_proxy=config_data.get("http_proxy"),
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/ads/googleads/oauth2.py", line 47, in initialize_credentials_wrapper
    credentials.refresh(Request())
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/oauth2/credentials.py", line 310, in refresh
    enable_reauth_refresh=self._enable_reauth_refresh,
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/oauth2/reauth.py", line 347, in refresh_grant
    _client._handle_error_response(response_data)
  File "/opt/home/qmpx/.local/lib/python3.7/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response
    raise exceptions.RefreshError(error_details, response_data)
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})

I have all tried all the suggestions posted in this group but it isnt helping a bit. 

Looking forward to a suggestion/advice.

Google Ads API Forum Advisor

unread,
May 3, 2022, 4:44:16 PM5/3/22
to vicky....@gmail.com, adwor...@googlegroups.com
Hi Vickey,

You may reach out to the issue tracker as this appears to be a client library specific issue.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


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