问题描述
我已经在Google操作中实现了帐户关联。我选择了具有隐式链接类型的OAuth。我已链接我的帐户,但在后续通话中没有访问令牌。在google文档中说:“在Google获得您的服务访问令牌后,Google会将该令牌附加到随后对您的Action的调用中,作为AppRequest的一部分。”请求中的用户信息应采用以下格式:
{
user : {
"idToken": string,"profile": {
object (UserProfile)
},"accesstoken": string,"permissions": [
enum (Permission)
],"locale": string,"lastSeen": string,"userStorage": string,"packageEntitlements": [
{
object (PackageEntitlement)
}
],"userVerificationStatus": enum (UserVerificationStatus)
}
}
google apprequest格式:https://developers.google.com/assistant/conversational/df-asdk/reference/webhook/rest/Shared.Types/AppRequest#User.FIELDS.access_token
但是我收到的请求不包含任何accesstoken。
{
user:
{ locale: 'en-GB',params: {},accountLinkingStatus: 'LINKED',verificationStatus: 'VERIFIED',packageEntitlements: [],lastSeenTime: '2020-11-09T09:07:54Z' }
}
google帐户关联文档:https://developers.google.com/assistant/identity/oauth2?oauth=implicit#flow
解决方法
我在应用程序请求的标题中找到了访问令牌
授权:'承载者
headers:
{ host: '5cf1a2690f0c.ngrok.io','user-agent': 'Google-ActionsOnGoogle/1.0','content-length': '885','accept-encoding': 'gzip,deflate,br',authorization: 'Bearer < accesstoken >','content-type': 'application/json;charset=UTF-8','google-actions-api-version': '3','google-assistant-signature':
'< google-assistant-signature >','x-forwarded-for': '66.249.84.212','x-forwarded-proto': 'https' }
根据文档,它将以以下格式显示在正文部分,但我在标题中找到了它。
{
user : {
"idToken": string,"profile": {
object (UserProfile)
},"accessToken": string,"permissions": [
enum (Permission)
],"locale": string,"lastSeen": string,"userStorage": string,"packageEntitlements": [
{
object (PackageEntitlement)
}
],"userVerificationStatus": enum (UserVerificationStatus)
}
}