0

so I've beentrying to retrieve the email associated with the current user using the google home.

Documentation is kind of hard to find on the subject and from what I could gather, I should be able to use the SignIn class from actions-on-google. So here is my setup.

DialogFlow -> Created two intent, one to start the sign in process, the other to follow up on the process. (The second one has the event 'actions_intent_SIGN_IN' to it.)

Actions on google config : Account Linking.

  • Selected - Yes, allow users to sign up for new accounts via voice
  • Selected - Linking Type : Google Sign In

And added the client id to my fulfillment layer by adding the clientId to my dialogflow config.

dialogflow({clientId})

So, when I run this in the emulator (I get the same exact thing on my google home device) I get an error as soon as my sign in goes to the followup intent (actions_intent_SIGN_IN), which is that my signin.status is Error. From there, I don't know what I can do to get more information on what this error is and how to fix it.

Any idea ? Thanks !

PS : It might not even be something that can be done ? Is there any other way to retrieve the email of the user ? I was able to retrieve it's name using Permission, but there's nothing more that SignIn for email as far as I know.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Why are you after their details? I ask because I started trying to use SignIn, but then I realized for notifications there is a different way to ask for permission to send push notifications, which also seems to return the user's email address without all the clientid stuff. However, my error I then hit was it said I could not ask for PII data (I had registered for kids), so my code does not work. Did you find the exact wording of the error message in the logs? That may help track down the problem. – Alan Kent Jun 05 '18 at 06:42
  • I am not looking to use that for notifications. I'm working on trying to fill a form quickly and having access to the email of the user would help greatly. – Philippe Bérubé Jun 06 '18 at 12:36

1 Answers1

0

I can show you how I get my email address with the Google Account linking: You need to have your accessToken available then you could use what is shown in this answer. The accessToken is in conv.user.access.token when the SignIn is completed.

In node this looks like that:

let link = "https://www.googleapis.com/oauth2/v1/userinfo?access_token="+accessToken;
    return new Promise(resolve => {
        request(link,(error, response, body) => {
            if (!error && response.statusCode === 200) {
                let data = JSON.parse(body);
                let name = data.given_name ? data.given_name : '';
                conv.ask(new SimpleResponse({
                    speech: "Hello "+ name + "!",
                    text: "Hello "+ name + "!"
                }));
                resolve();
            } else {
                console.log("Error in request promise: "+error);
                resolve();
            }
        })
    })

Everything you need should be in the data object.

Hope it helps. About your error, I am not sure but try doing all step in the link above. I'm using the Sign-In required box with Dialogflow and not a new SignIn but it should work the same.

Rémi C.
  • 339
  • 2
  • 12
  • 1
    I was led to believe that when using "Linking Type: Google Sign" would work without any OAuth service... Maybe that is where I'm wrong ? – Philippe Bérubé Jun 06 '18 at 10:48
  • It is true, as it was recently introduced. You are right on that. It works the same by the way. – Rémi C. Jun 06 '18 at 11:45
  • Sadly when I do it that way, I'm not receiving any token.... nor name, nor anything. (Error or not) – Philippe Bérubé Jun 06 '18 at 12:12
  • This code will work only if your account linking is successful. Do you have any error ? – Rémi C. Jun 06 '18 at 12:20
  • { '@type': 'type.googleapis.com/google.actions.v2.SignInValue', status: 'ERROR' } and this "sharedDebugInfoList": [ { "name": "Account Linking Url", "debugInfo": "url", "subDebugEntryList": [] } ] } The last one reference oauth... which doesn't make sense to me, as I didn't choose oauth... This feels like a bug :/ – Philippe Bérubé Jun 06 '18 at 12:56
  • When you click on the link of debufInfo and you connect, doesn't it give you a token ? – Rémi C. Jun 06 '18 at 12:59
  • No that gives me this error : "OAuth URL not provided. Re-run linking flow" Which to me doesn't make any sense, as this is not a OAuth flow... – Philippe Bérubé Jun 06 '18 at 13:59
  • What did you do in the Account Linking section of your project? – Rémi C. Jun 06 '18 at 14:10
  • As said in my question 'Actions on google config : Account Linking. Selected - Yes, allow users to sign up for new accounts via voice Selected - Linking Type : Google Sign In' – Philippe Bérubé Jun 07 '18 at 11:12
  • I don't know, sorry :( Maybe you could try setting Oauth with Google and check if the code will work, otherwise good luck – Rémi C. Jun 07 '18 at 11:51