尝试使用OAuth2授权代码流在Web模拟器中测试auth,https://developers.google.com/actions/tools/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将使用流程中提供的授权代码调用您的令牌 endpoints .
但后来我得到了:
result_code=FAILURE&result_message=Account+linking+failed
这一切似乎都在我的身边,但谷歌正在回归失败 .
1 回答
在我的情况下,我的令牌 endpoints 返回我的标准令牌响应对象,其中包括 access_token , refresh_token , expires_in , session_state 和另一个为此目的不需要但是我的令牌响应标准的令牌 .
当我在Googles游乐场测试同样的响应时,它很好:https://developers.google.com/oauthplayground/
但在使用助理网址时则不是这样:https://assistant.google.com/services/auth/handoffs/auth/start?provider=your-google-project-id_dev&scopes=your-scopes&return_url=https://www.google.com/
事实证明,助手不喜欢响应对象中的多余属性 .
我还没有完全确定什么是允许的,但是到目前为止你可以:
有了这些我现在得到: