Redirect URI refused to connect

1,153 views
Skip to first unread message

Somya Malviya

unread,
Jun 2, 2022, 6:53:31 AM6/2/22
to Google Ads API and AdWords API Forum
Hey team,

I have been trying to use the Google Ads API, and I followed the instructions given by the Google Ads Developer portal and videos. The API connection is successful using the OAuth Playground where I have input the redirect URI mentioned, within the web application. However, when I am trying to run it using the Python code for generating a refresh token (I have used the github code) with redirect URI as (http://localhost:8080), once I copy the code and sign in using my credentials, it displays the following error: localhost refused to connect.

Attached is the error message and code snippets:
GAds python2.PNG
GAds python1.PNG
Google Ads API error.PNG

Google Ads API Forum Advisor

unread,
Jun 2, 2022, 11:31:33 AM6/2/22
to somya....@groupm.com, adwor...@googlegroups.com
Hi Somya,

Thank you for raising your concern to my team.

Could you try using this sample code instead for generating user credentials and follow the instruction below based on the authentication flow you are currently implementing?

"If using Web flow, the redirect URL must match exactly what’s configured in GCP for the OAuth client. If using Desktop flow, the redirect must be a localhost URL and is not explicitly set in GCP from google_auth_oauthlib.flow import Flow" 

Let me know what goes after. 

Best regards, 
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bbCEC:ref

Somya Malviya

unread,
Jun 2, 2022, 10:52:06 PM6/2/22
to Google Ads API Forum Advisor, adwor...@googlegroups.com, Abdul Shayesht

Hey Jinky,

 

Thank you so much for helping me out with the Authentication process. I was able to generate the refresh token successfully.

 

However, when I am trying to run a reporting example (get keywords stats from the documentation examples) using Python, it is giving me the following error:

 

I have installed the latest version of google-ads in Anaconda. I have also stored the credentials, customer-id, developer token and other details in the google-ads.yaml file.

 

Here are the screenshots of the entire code:

 

Could you please help me resolve this as well?

 

Thanks,

SOMYA MALVIYA (She/Her)

Data Analyst | GroupM Australia

M: +61 432 011 048

WPP AUNZ Campus (Berry street)

Level 11, 65 Berry Street

North Sydney

NSW 2060

www.groupm.com

@groupmworldwide

Follow us on LinkedIn

 

 

GroupM acknowledges the Traditional Owners of Country throughout Australia.

I recognise the Gadigal People of the Eora Nation – the land on which I live and work, and pay respect to Elders past and present.

 

 

 

From: Google Ads API Forum Advisor <ads...@forumsupport.google>
Sent: Friday, 3 June 2022 1:31 AM
To: Somya Malviya <somya....@groupm.com>
Cc: adwor...@googlegroups.com
Subject: RE: Redirect URI refused to connect

 

Hi Somya,

Thank you for raising your concern to my team.

Could you try using this sample code instead for generating user credentials and follow the instruction below based on the authentication flow you are currently implementing?

"If using Web flow, the redirect URL must match exactly what’s configured in GCP for the OAuth client. If using Desktop flow, the redirect must be a localhost URL and is not explicitly set in GCP from google_auth_oauthlib.flow import Flow" 

Let me know what goes after. 

Best regards, 

Image removed by sender. Google Logo

Jinky

Google Ads API Team

 

Image removed by sender.

ref:_00D1U1174p._5004Q2bbCEC:ref

Privileged/Confidential Information may be contained in this message. If you are
not the addressee indicated in this message (or responsible for delivery of the
message to such person), you may not copy or deliver this message to anyone. In
such case, you should destroy this message and kindly notify the sender by reply
email. Please advise immediately if you or your employer does not consent to email
for messages of this kind. Opinions, conclusions and other information in this
message that do not relate to the official business of Group M Worldwide LLC and/or
other members of the GroupM group of companies shall be understood as neither given
nor endorsed by it. GroupM is the global media investment management arm of WPP.
For more information on our business ethical standards and Corporate Responsibility
policies please refer to WPP's website at http://www.wpp.com/WPP/About/
Reply all
Reply to author
Forward
0 new messages