0
votes

I have a Google Assistant (Actions on Google) app where I want the user to log in. I use actions-on-google with DialogFlow which in turn has a webhook.

For a specific action where signin in required, in the webhook, I launch app.askForSignIn();

I have an intent called actions.intent.SIGN_IN which has an event called actions_intent_SIGN_IN. On this action, I check app.getSignInStatus() and I get null for this.

Am I missing something? Will Google Assistant / Actions on Google do something to extract link the token and scopes from oauth and associate it with the user?

3

3 Answers

3
votes

I was able to make it work on my app but I'm not calling app.askForSignIn(), instead I've checked the option "Sign in required" on the DialogFlow integration with Google Assistant, then I provided all informations regarding client ID and secret and Authorization and Token URLs in the "Account linking" section of the App's overview on the Action on Google console.

I basically followed this guide.

PS: To make it work on the console either you have to sign in from a smartphone or call the auth URL directly in a browser window.

0
votes

hi rochan i had same problem a while ago see my post its still an open issue for me. Google Actions SDK Sign-In implicit flow

But it hadnt much priority for me. What you can try is using a google assistant enabled smartphone and test there instead of inside the simulator. Maybe it works.

0
votes

You have to enable the Sign in Required option in Google assistant integration settings in dialogflow enter image description here

After enabling this, Use Account Linking option in the actions-on-google overview and follow the below steps

We have to enable the webhook first and we can see how to enable the webhook in the dialogflow fulfillment docs.

Open your project under google cloud console 1. Go to google cloud console -> APIsand Services -> Credentials -> OAuth 2.0 client IDs -> Web client -> Note the client ID, client secret from there -> Download JSON - from json note down the project id, auth_uri, token_uri -> Authorised Redirect URIs -> White list our app's URL -> in this URL fixed part is https://oauth-redirect.googleusercontent.com/r/ and append the project id in the URL -> Save the changes

  1. Actions on Google -> Account linking setup 1. Grant type = Authorisation code 2. Client info 1. Fill up client id,client secrtet, auth_uri, token_uri 2. Enter the auth uri as https://www.googleapis.com/auth and token_uri as https://www.googleapis.co.in 3. Save and run from google assistant on some device. 4. It will show an error while running on the google assistant, but dont worry. 5. Come back to the account linking section in the assistant settings and enter auth_uri as https://accounts.google.com/o/oauth2/auth and token_uri as https://accounts.google.com/o/oauth2/token 6. Put the scopes as https://www.googleapis.com/auth/userinfo.profile and https://www.googleapis.com/auth/userinfo.email and weare good to go. 7. Save the changes.

  2. In the hosting server logs, we can see the access token value and through access token, we can get the details regarding the email address.

  3. Append the access token to this link "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" and we can get the required details in the resulting json page.

Additionally, to get the Username and email address, you can use this below snipet

accessToken = req.get("originalRequest").get("data").get("user").get("accessToken")
r = requests.get(link) print("Email Id= " + r.json()["email"]) print("Name= " + r.json()["name"])