gpt4 book ai didi

dialogflow-es - 使用 Google 操作从用户那里获取电子邮件

转载 作者:行者123 更新时间:2023-12-03 15:29:45 25 4
gpt4 key购买 nike

我想按照文档中的说明使用 Google Actions 接收用户电子邮件 here但是文档谈到了 EMAIL 权限,但是当我阅读权限文档时 here我找不到任何 EMAIL 权限。有什么帮助吗?如何接收用户电子邮件?

最佳答案

这是有效的,您可以通过帐户链接来做到这一点。

我们必须先启用 webhook,我们可以在对话流实现文档中看到如何启用 webhook
如果我们要使用 Google Assistant,那么我们必须首先在集成中启用 Google Assistant 集成。
然后按照下面提到的步骤在谷歌上的操作中进行帐户链接:-

  • 转到谷歌云控制台
  • 转到 API 和服务 -> 凭据 -> OAuth 2.0 客户端 ID -> Web 客户端
  • 请注意客户端 ID,来自那里的客户端 key
  • 下载 JSON - 从 json 中记下项目 ID、auth_uri、token_uri
  • 转到授权重定向 URI
  • 白名单我们的应用程序的 URL,在这个 URL 固定部分是 https://oauth-redirect.googleusercontent.com/r/[project-Id] (将 [project-Id] 替换为您的项目 ID)
  • 保存更改
  • 转到 Actions on Google(https://console.actions.google.com) -> 帐户关联设置
  • 选择授予类型 = 授权码
  • 客户信息
  • 填写客户端id、客户端密码、auth_uri、token_uri
  • 输入任何随机 url 作为 授权网址 token_uri https://example.com/authhttps://example.com/token
  • 保存
  • 在谷歌助手上运行会报错,不过不用担心
  • 回到助手设置中的账号关联部分,这次输入正确的 auth_uri https://accounts.google.com/o/oauth2/auth
    token_uri https://accounts.google.com/o/oauth2/token

    note that it is some sort of problem in from their side that not allows you to use this url in first hit and will keep saying "Generic URLs are not allowed. You must provide a valid token url specific to your Assistant app." so just give any random url in first hit and save, then comeback again it will allow you these urls :-)

  • 将范围设为 https://www.googleapis.com/auth/userinfo.profilehttps://www.googleapis.com/auth/userinfo.email
    很高兴去。
  • 保存更改。
  • 在托管服务器日志中,我们可以看到访问 token 值,通过访问 token ,我们可以获得有关电子邮件地址的详细信息。
  • 将访问 token 附加到此链接“https://www.googleapis.com/oauth2/v1/userinfo?access_token=”,我们可以在生成的 json 页面中获取所需的详细信息。
  • 写下这段代码
    accessToken = req.get("originalRequest")
    .get("data")
    .get("user")
    .get("accessToken")

    r = requests.get(link) // make get request to link

    print("Email Id: " + r.json()["email"])
    print("Name: " + r.json()["name"])
  • 关于dialogflow-es - 使用 Google 操作从用户那里获取电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44086605/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com