0

I have successfully linked the account in dialogflow. I can also validate the access token received in the request.

but in case of invalid access token I want to ask the user to again link their account by first unlinking the account from the webhook and then send the actions.intent.SIGN_IN.

I am able to do the unlinking from test simulator of Actions Console manually but is there any way to unlink the account from the webhook or is there any way to unlink the account programmatically?

Prisoner
  • 49,922
  • 7
  • 53
  • 105

1 Answers1

1

The only way to do this from your webhook is to return a status_code of 401. Yep, you heard that right. The expected solution is to return an error.

I wouldn't believe it myself, if it didn't come straight from AoG support...

return a HTTP 401 Unauthorized error from your webhook, to any request to indicate to Google that a new access token must be acquired. Google then exits the app with the error message "app assistant isn't responding right now. Try again soon." When the user invokes your app again, he is required to account link.

So the expected solution is to for your action to respond as if your webhook is broken, expect the user to try again despite the "error", then they'll not have a token and will follow the unlinked flow.

Timothy Aaron
  • 3,059
  • 19
  • 22
  • While this solution technically can work, I dont think that an action that returns an error message during the conversation can pass the review by the Google team. So if someone were to use this solution, they should keep in mind it might prevent them from releasing their action to the public. – Jordi Apr 16 '20 at 05:39
  • I don't blame you. Sounds crazy, right? But that quote is *from* AoG support. Our action has passed certification ~once a month for years, including two days ago. Again, this is the solution recommended by AoG. – Timothy Aaron Apr 16 '20 at 10:36
  • 1
    https://developers.google.com/assistant/identity/google-sign-in-oauth#check_if_the_google_account_is_already_present_in_your_authentication_system – Timothy Aaron Apr 16 '20 at 10:52