首页 > 解决方案 > Google Drive API Quickstart.py 错误 400:redirect_uri_mismatch

问题描述

我正在使用https://developers.google.com/drive/api/v3/quickstart/python访问 Google Drive Api,但 Google 不断抛出redirect_uri_mismatch错误。

我将错误中的 localhost:number 添加到 Web 应用程序的客户端 ID 中的授权重定向 URI,但是每当我运行 时quickstart.py,本地主机号都会更改。

我在 StackOverflow 上看到有很多关于这个问题的问题,我已经花了几个小时来解决我的问题,但我还没有找到似乎可以为我解决问题的答案。

有任何想法吗?


尝试过的答案,除其他外,


目前

在此处输入图像描述

标签: pythongoogle-drive-apigoogle-authentication

解决方案


Tanaike的评论和回答在这里有效:Google APIs OAuth 2.0 redirect_uri_mismatch 错误

因此,在quickstart.py中进行以下更改,

creds = flow.run_local_server(port=0) 

到,

creds = flow.run_local_server(port=8080) 

何时http://localhost:8080/在 URI 列表中。


推荐阅读