redirect_uri_mismatch 当从 Google 家庭模拟器链接 OAuth2 帐户时

redirect_uri_mismatch when OAuth2 account linking from Google Home Simulator

我正在开发一个帐户 linking 集成,用于 "Actions on Google" 与 API.AI 的集成,以便与 Google 主页一起使用。当我在模拟器中测试这个代理时 (https://developers.google.com/actions/tools/web-simulator)

不出所料,这是我的回复:

{
    "response": "It looks like your conference manager account is not linked yet. You can link conference manager to your Google Account from the Google Home app.",
    "audioResponse": "//NExAARC..."content_copy,
    "debugInfo": {
        "sharedDebugInfo": [
            {
                "name": "Account Linking Url",
                "debugInfo": "https://assistant.google.com/services/auth/handoffs/auth/start?provider={project-id}_dev&return_url=https://www.google.com/"
            }
        ]
    }
}

但是,当我按照

res.debugInfo.sharedDebugInfo[0].debugInfo

link,我得到了标准的 redirect_uri_mismatch 错误页面,其中包含详细信息:

The redirect URI in the request, https://oauth-redirect.googleusercontent.com/r/my-project-id, does not match the ones authorized for the OAuth client. Visit https://console.developers.google.com/apis/credentials/oauthclient/my-client-id?project=my-client-id to update the authorized redirect URIs.

It's of course not possible to add the googleusercontent domain to the redirects, and this isn't the redirect I have specified in my API.AI Actions on Google intergration.

在 API.AI 方面,我的 Auth Url 是标准的 Google: https://accounts.google.com/o/oauth2/v2/auth

我的代币 URL 是: https://myendpoint.com/google-home-token-endpoint 范围填写为 calendar

在 google 开发人员控制台上,我将令牌 URL 设置为与 API.AI 中相同,项目 id/client id 与参考中的相同请求。

这是一个已知问题吗?我可以尝试额外的调试工作吗?

请参阅 Leon 对我的原始问题的评论。

目前无法为您不拥有的 API 进行帐户链接。

我也很困惑,为什么你不能在 Google 上使用 Google 登录进行帐户 linking 操作。

但是,我使用 Login With Amazon 完成了这项工作,方法如下:

  1. 在 api.ai 中,选择集成 -> google 上的操作。
  2. 选择一个调用名称在google developers console
  3. 中创建一个项目
  4. 输入对应的google项目ID
  5. 选择您的欢迎意图
  6. 转到亚马逊开发者控制台登录 亚马逊
  7. 在允许的来源下,输入 https://accounts.google.com/
  8. Under Allowed Return URLs, put https://oauth-redirect.googleusercontent.com/r/my-project-id (with 您的 google 项目 ID(以上)
  9. 返回 Actions on Google 弹出窗口,输入在 Amazon 开发人员控制台中创建的客户端 ID 和客户端密码。
  10. 设置授权类型=隐式
  11. 设置权限URL = https://www.amazon.com/ap/oa

  12. 设置范围 = 配置文件

  13. 授权并预览,然后按照问题中的描述继续将 res.debugInfo.sharedDebugInfo[0].debugInfo 中的 link 粘贴到浏览器会话。它将成功link到关联的亚马逊帐户。

问题是 - 为什么我可以使用 Amazon 作为 OAuth2 的身份提供者使用 Web 联合身份验证,而不是 Google 在设置帐户 linking with Actions on Google 时?