TommyBs
TommyBs

Reputation: 9646

Actions on Google V2 idToken not sent

Looking at the docs for the appRequest for actions on google https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest

The user object says that the userId property is now deprecated and that we should use the idToken instead https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest#user

However testing out a V2 action in the simulator, my response only includes a userId property and not the idToken

I'm definitely using V2 of the API and this doesn't say it's an optional field when linking accounts (for what it's worth I haven't done any account linking).

Should this field be included?

Upvotes: 1

Views: 99

Answers (1)

Prisoner
Prisoner

Reputation: 50701

That's not quite what that page says.

Yes, it says the userId property is deprecated - it does not show any replacement there. It was deprecated without a direct replacement, although you can create one yourself if needed.

It does not say the idToken replaces it, although you can get a unique ID from the idToken, it doesn't do so directly. It also doesn't give you the idToken unless you take some steps to enable it.

To use the idToken to get a user identifier, you need to do a few things:

  1. Turn on Google Sign In for Assistant.
  2. Request the user sign into your Action using Google Sign In for Assistant or have them sign via other means (Google Sign In for the web or for mobile) to the same project.
  3. When you get the idToken, verify and extract the JWT payload. If you're using the action-on-google library, it will do this for you. If not, this is a standard JWT token which you should verify and the payload includes the ID.

Upvotes: 2

Related Questions