Search code examples
actions-on-google

Where to find user's access token in requests from Assistant to fulfilment webhook?


According to the documentation for implementing OAuth account linking with Google Assistant, "After the user has completed the account linking flow, every subsequent request sent from the Assistant to your fulfillment webhook contains an access token."

Well, Google, it'd be nice if your documentation included details of where to find this access token!

Many of the questions on SO asking this relate to Dialogflow, which I am not using, but in any case, per the suggestions in some of the answers to these questions I haven't been able to find the info in conv.user.access.token, conv.user.profile.payload or user.access_token. I haven't been able to access the headers of the request.

In the actions simulator's logs I can see that the requests include a user.params.bearerToken property, which I can't find documented anywhere, but the value contained therein, whilst it looks to be in the correct format, doesn't match any of the tokens my OAuth server has issued. It could be a cached value from my extensive testing to get account linking working, but I've unlinked and relinked my account, and reset the test, and the value never changes, so perhaps it's not even supposed to be the access token from the OAuth server?

Does anyone know where, in 2022, the access token for the linked user can be found in requests from Google Actions to the fulfilment webhook, as promised by the docs?


Solution

  • Eventually I found that the access token was available in conv.user.params.bearerToken. It's been a little while now so I can't remember why the value in this property seemed not to match what was expected at the time I wrote the question, but I am now successfully using it.