Search code examples
dialogflow-esactions-on-googlegoogle-assistant-sdkaccount-linking

Account Linking with google assistant not getting accessToken in apprequest


I have implemented account linking in google actions. I've chosen OAuth with Implicit linking type. i got my account linked, but i'm not getting access-token in subsequent calls. In the google documentation says :" After Google has obtained an access token for your service, Google will attach the token to subsequent calls to your Action as part of the AppRequest." The user information in the request should be in the following format:

{
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 format : https://developers.google.com/assistant/conversational/df-asdk/reference/webhook/rest/Shared.Types/AppRequest#User.FIELDS.access_token

but i'm getting the request which is not containing any accessToken.

{
user:
   { locale: 'en-GB',
     params: {},
     accountLinkingStatus: 'LINKED',
     verificationStatus: 'VERIFIED',
     packageEntitlements: [],
     lastSeenTime: '2020-11-09T09:07:54Z' }
} 

google account linking docs :https://developers.google.com/assistant/identity/oauth2?oauth=implicit#flow


Solution

  • I found the access token in the header of the app request

    authorization:'Bearer < accesstoken > '

    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' }
    

    according to the docs, it will be in the body section in the following format but I found it on the header.

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