-1

我已经在谷歌操作中实现了帐户链接。我选择了具有隐式链接类型的 OAuth。我已关联我的帐户,但在随后的通话中我没有获得访问令牌。在谷歌文档中说:“在谷歌为您的服务获得访问令牌后,谷歌会将令牌作为 AppRequest 的一部分附加到对您的操作的后续调用。” 请求中的用户信息应采用以下格式:

{
user : {
  "idToken": string,
  "profile": {
    object (UserProfile)
  },
  "accessToken": string,
  "permissions": [
    enum (Permission)
  ],
  "locale": string,
  "lastSeen": string,
  "userStorage": string,
  "packageEntitlements": [
    {
      object (PackageEntitlement)
    }
  ],
  "userVerificationStatus": enum (UserVerificationStatus)
}
}

谷歌应用请求格式: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' }
} 

谷歌帐户链接文档:https ://developers.google.com/assistant/identity/oauth2?oauth=implicit#flow

4

1 回答 1

1

我在应用请求的标头中找到了访问令牌

授权:'承载<访问令牌>'

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)
}
}
于 2020-11-19T08:52:50.140 回答