How to extract the email Id and user name, which is linked with the google home , at the fullfilment of the google dialogflow flow

爷,独闯天下 提交于 2019-12-27 01:58:46

问题


I want to get the linked email id with google home , when user triggers an intent. I have followed the following link How to get user's unique identity from google home's voice match profile?

I am following Rajat's answer and have done till the 2nd step.

But I am not getting the accessToken in the user's object. I neeed this token to get the user details from this api endpoint: "https://www.googleapis.com/oauth2/v1/userinfo?access_token="

Instead I am getting this user object from the fulfillment JSON: { locale: 'en-GB', userId: '15391770952311649498774' }.

How can I get the access token?


回答1:


The Google Assistant will only send your Action an auth token if you have connected an OAuth service to your Action through Account Linking. This works if you have an OAuth server and a service behind it that will use the auth token to give you the information you want.

You're trying to get that information from the userinfo endpoint with Google's API, however. Which means you need to use Google's OAuth server. Rajat's answer gives you the information to do that. However, this won't work. Google does not allow you to use their OAuth endpoints for the Assistant - you must use an OAuth endpoint you control (such as one through Auth0, or one you run yourself).

But there is still a way to get the information you want.

You can use Google Sign In for Assistant. In this scheme, you will get an identity token if the user gives permission for your Action to get it.

You will need to request permission using a sign-in helper, but if the user authorizes it, you'll get an identity token which you can decode (you don't need to send it to a service) to get public profile information which may include their name and email address.



来源:https://stackoverflow.com/questions/52753920/how-to-extract-the-email-id-and-user-name-which-is-linked-with-the-google-home

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!