Google Oauth 2.0 redirect_uri_mismatch -回调时端口改变
本文关键字:回调 改变 uri Oauth redirect Google mismatch | 更新日期: 2023-09-27 18:02:35
我使用Google. api . auth . oauth2 . googlewebauthorizationbroker . authorizeasync()来验证一个Google帐户,问题是Google在我登录到我的Google帐户后返回一个400错误:
请求:http://localhost:40745/authorize/中的重定向URI与注册的重定向URI不匹配。
但是我的mvc应用程序运行在46423,并且在开发控制台中重定向URI设置为http://localhost:46423/authorize/。我错过了什么?
每次调试时重定向URI都会更改。您应该将http://localhost/authorize/
添加到凭据页面中的重定向URI列表中。
问题在quickstart.py
文件的flow.run_local_server(port=0)
行
当port=0时,操作系统将动态分配一个可用的端口号,这在默认端口已经被另一个进程使用的情况下很有用。因此,您需要将其更改为例如flow.run_local_server(port=8000)
并在凭证页面中注册。