Authorization problem

381 views
Skip to first unread message

Laurent Petr

unread,
Feb 17, 2022, 3:14:34 AM2/17/22
to Google Ads API and AdWords API Forum
Hi all,

I'm trying for the first time to use Google Ads API and I'm following these instructions :

I have a problem with "Run the AuthenticateInDesktopApplication example, which will prompt you for your OAuth2 client ID and secret".
After having asked me for OAuth2 client ID and  OAuth2 client secret, it tells me to visit an URL. But this URL says:
Erreur 400 : redirect_uri_mismatch
The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at https://console.developers.google.com/apis/credentials/oauthclient

Yet, when I created my client id, I have choosen "Web application"...

What can I do?
Thanks!
Laurent


Google Ads API Forum Advisor

unread,
Feb 17, 2022, 10:22:18 PM2/17/22
to laure...@gmail.com, adwor...@googlegroups.com
Hi Laurent,

Thank you for reaching out to our API support team.

If you wish to follow the desktop app flow, you may follow this guide for PHP instead. Should you continue to encounter issues, you may write back to our team and specify which step in the guide the issue was encountered.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


ref:_00D1U1174p._5004Q2WwZFQ:ref

Laurent Petr

unread,
Feb 18, 2022, 5:12:37 AM2/18/22
to Google Ads API and AdWords API Forum
Hi Peter,

Thanks!

"php AuthenticateInDesktopApplication.php" is whats I tried yesterday.
But, as my app is a web app, I've just tryed "php AuthenticateInWebApplication.php".
The detailed message doesn't speak of king of app now, It's a problem of authorized URI :
"Erreur 400 : redirect_uri_mismatch
Vous ne pouvez pas vous connecter à cette appli, car elle ne respecte pas le règlement OAuth 2.0 de Google.
Si vous êtes le développeur de l'appli, enregistrez l'URI de redirection dans Google Cloud Console."

The URI is with authorization problem is: 
I tryed to replace 127.0.0.1 by the domain name I have authorized in the console, but the error is the same.

Best regards
Laurent

Laurent Petr

unread,
Feb 18, 2022, 5:44:16 AM2/18/22
to Google Ads API and AdWords API Forum
Peter,

The error is solved and I could validate the authorization, but I was redirected to http://127.0.0.1:44807/oauth2callback
But this URI doesn't exists, so it's an error page.

Thanks
Laurent

Google Ads API Forum Advisor

unread,
Feb 21, 2022, 2:27:14 AM2/21/22
to laure...@gmail.com, adwor...@googlegroups.com
Hi Laurent,

I am also a member of the Google Ads API team and let me provide support to your concern.

Upon checking your concern, it appears that this is more client library related. With this, I am afraid that our team could not provide further support here as it is outside of our expertise already. With this, I would suggest to reach out to author of the PHP client library instead via this link as they are more equipped on this topic.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2WwZFQ:ref

Laurent Petr

unread,
Feb 21, 2022, 3:56:08 AM2/21/22
to Google Ads API Forum Advisor, adwor...@googlegroups.com

Hi Ernie

Ok, I will post on the other group.

But could you help me to understand how the authorization should work?
I want to create a small web app.
According to your documentation (https://developers.google.com/google-ads/api/docs/client-libs/php/oauth-web?hl=en), I need to execute the authorization URL from my browser ("visit the following URL"), so my browser is redirected to the script that should deliver the refreshToken.
But I'm redirected to 127.0.0.1, so to my own computer, but as it's a web app, I have nothing on my computer and it can't work...

Thanks!

Best regards
Laurent

Google Ads API Forum Advisor

unread,
Feb 21, 2022, 2:28:11 PM2/21/22
to laure...@gmail.com, adwor...@googlegroups.com
Hi Laurent,

The way the web flow works is that the app is listening in on the port sent to the server when authenticating, so the code is sent directly to the app via the redirect instead of having to paste the code in. I would suggest you reach out to the author of the PHP client library instead via this link. Different client libraries state different types of redirect URL's.

Regards,

Google Logo
Aryeh
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2WwZFQ:ref

Laurent Petr

unread,
Feb 23, 2022, 3:08:33 AM2/23/22
to Google Ads API and AdWords API Forum
Hello,

On Github, they said to see with API support...
They said also, I shoud use AuthenticateInDesktopApplication.php even with a web app, and not AuthenticateInWebApplication.php

I tryed again with  AuthenticateInDesktopApplication.php and I have the message :

"Erreur 400 : redirect_uri_mismatch
The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at https://console.developers.google.com/apis/credentials/oauthclient"

Best regards
Laurent

Google Ads API Forum Advisor

unread,
Feb 23, 2022, 10:55:56 AM2/23/22
to laure...@gmail.com, adwor...@googlegroups.com
Hi Laurent,

For authenticating in desktop application flow, the credentials generated in the GCP project are for a desktop app. You can generate a client ID and secret by following the linked instructions and try with those credentials.
Reply all
Reply to author
Forward
0 new messages