5

I'm using Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync() to authenticated a Google account, the problems is that Google returns a 400 error after I've logged into my Google account:

The redirect URI in the request: http://localhost:40745/authorize/ did not match a registered redirect URI.

But my mvc application runs at 46423, also the Redirect URI is set to http://localhost:46423/authorize/ in the dev console. What am I missing?

Martin Lindgren
  • 374
  • 2
  • 14

2 Answers2

11

The redirect URI changes each time you debug. You should add http://localhost/authorize/ to your redirect URI list in the Credential page.

Martin Lindgren
  • 374
  • 2
  • 14
Ilan Olkies
  • 413
  • 5
  • 10
2

The problem is at the line flow.run_local_server(port=0) of the quickstart.py file.

When port=0, the operating system will dynamically assign an available port number, which is useful in cases where the default port is already in use by another process. So you need to change this to say for example flow.run_local_server(port=8000) and register in the credentials page.

Ranji Raj
  • 778
  • 4
  • 18