【问题标题】:Google Drive API Quickstart.py Error 400: redirect_uri_mismatchGoogle Drive API Quickstart.py 错误 400:redirect_uri_mismatch
【发布时间】:2021-01-05 10:46:48
【问题描述】:

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

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

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

有什么想法吗?


尝试过的答案,其中包括


目前

【问题讨论】:

  • 你的redirect_uri是什么?
  • 我已经删除了我尝试过的所有 URI,只保留了 http://localhost:8080/
  • 顺便说一下在注释中添加代码sn-p :p
  • 虽然我不确定这是否是直接的解决方案,但如果您使用the script of Quickstart,请将creds = flow.run_local_server(port=0)修改为creds = flow.run_local_server(port=8080),并再次测试。使用port=0的时候,好像使用的是随机端口。
  • 这能回答你的问题吗? Google APIs OAuth 2.0 redirect_uri_mismatch error

标签: python google-drive-api google-authentication


【解决方案1】:

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

所以在quickstart.py,进行如下修改,

creds = flow.run_local_server(port=0) 

到,

creds = flow.run_local_server(port=8080) 

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-02
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 2015-09-07
    • 2021-06-28
    • 2021-10-14
    • 1970-01-01
    相关资源
    最近更新 更多