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.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 on the web visit
https://groups.google.com/d/msgid/adwords-api/010fc4ca-76a7-47ad-8b74-6b4ba6778a88n%40googlegroups.com.