2

尝试使用 OAuth2 授权代码流在 Web 模拟器中测试身份验证,https://developers.google.com/actions/tools/web-simulator

请参阅:https ://developers.google.com/actions/tools/testing#testing_account_linking_with_google_home_web_simulator

并且: https ://developers.google.com/actions/develop/identity/oauth2-code-flow

如果您已将您的操作设置为要求对您的授权服务进行授权,那么当您尝试访问您的操作时,助手会建议您需要关联您的帐户。在同一个响应中,模拟器提供了一个用于启动链接过程的 URL,请参阅:

"debugInfo": {
    "sharedDebugInfo": [
        {
            "name": "Account Linking Url",
            "debugInfo": "https://assistant.google.com/services/auth/handoffs/auth/start?provider=your-google-project-id_dev&scopes=your-scopes&return_url=https://www.google.com/"
        }
    ]
}

调用此 URL(粘贴到浏览器中)将引导您完成 OAuth2 流程,假设所需的用户操作成功,Google 将使用流程期间提供的授权代码调用您的令牌端点。

但后来我得到:

result_code=FAILURE&result_message=Account+linking+failed

这一切似乎都在我身边工作,但谷歌返回失败。

4

1 回答 1

5

就我而言,我的令牌端点正在返回我的标准令牌响应对象,其中包括一个access_token、一个refresh_token、一个expires_in、一个session_state和另一个不需要为此目的但对我的令牌响应来说是标准的令牌。

当我在 Google 的操场上测试同样的响应时,它很好: https ://developers.google.com/oauthplayground/

但使用 Google 助理网址时并非如此:https://assistant.google.com/services/auth/handoffs/auth/start?provider=your-google-project-id_dev&scopes=your-scopes&return_url=https: //www.google .com/

事实证明,Assistant 不喜欢响应对象中的多余属性。

我还没有完全确定什么是允许的,什么是不允许的,但到目前为止你可以拥有:

{
    "token_type": "Bearer",
    "access_token: "xxx",
    "refresh_token": "yyy",
    "expires_in": "zzz"
}

有了这些,我现在得到:

result_code=SUCCESS
于 2017-03-30T09:22:17.533 回答