【发布时间】: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