【问题标题】:What should my URI be for Google Cloud APIGoogle Cloud API 的 URI 应该是什么
【发布时间】:2021-09-18 09:01:54
【问题描述】:

我想通过我计算机上的 python 脚本使用 Gmail API 发送电子邮件。

这是我目前的代码:

test.py

from google_auth_oauthlib.flow import InstalledAppFlow
flow = InstalledAppFlow.from_client_secrets_file('client_secret.json',scopes=['email'], redirect_uri='http://localhost/authorize/')
flow.run_local_server()

当我执行这个时,它会将我重定向到一个单独的 url 显示这个

我对这个问题的理解是,我需要一个redirect uri 与我的谷歌云平台仪表板上的这个应用程序相匹配。唯一的事情是我只想在本地运行它,所以我放置了 uri http://localhost/authorize

为了确认,我确实在 Google Cloud Platform 上将 http://localhost/authorize 添加到了我的 redirect uri

我引用了我找到的这个答案,但找不到我的解决方案: Correct redirect URI for Google API and OAuth 2.0

【问题讨论】:

    标签: python google-api gmail google-api-python-client


    【解决方案1】:

    我发现我需要一个重定向 URI,因为我为 Web 应用而不是桌面应用创建了 OAuth2 密钥。在这种情况下,不需要重定向 uri。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-11
      • 2017-09-21
      • 2019-05-13
      • 2018-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多