Is there a way to implement Google Sign-in via voice using Jovo framework?
If not - is there a way to use Actions on Google node.js sdk inside a Jovo app?
Google Sign-In in Jovo
How to get user logged in email in Jovo web hook handler?
answering my own question, I found something in the docs: https://www.jovo.tech/docs/reference/GoogleAction.html#main
I already enabled Sign In with voice in Action on Google console, and used this:
this.$googleAction.askForSignIn(speech)
in my app. First test returned a prompt from AoG to sign up
I’ll update with full solution when I get it - unless someone can do it quicker
so the next step is to create an intent:
ON_SIGN_IN () {
…
}
And inside try to get user profile data, hoping to provide access to email address.
The intent works, but I can’t get user profile data.
I tried this:
let profile = await this.$googleAction.$user.getProfile()
but it returns undefined.
Please help.
I found the problem, and the the solution too!
here’s the working ask for sign-in and sign-in confirmation intent:
async ASK_FOR_SIGNIN () {
const speech = 'To receive emails'
this.$googleAction.askForSignIn(speech)
}
async ON_SIGN_IN () {
if (this.$googleAction.getSignInStatus() === 'OK') {
// get token
const tokenId = this.$originalRequest.user.idToken
// decode token
const tokenUrl = 'https://oauth2.googleapis.com/tokeninfo?id_token=' + tokenId
try {
const response = await axios.get(tokenUrl)
const tokenData = response.data;
// pull email from the decoded token
this.tell(`User email is: ${tokenData.email}`);
} catch (error) {
console.error(error);
this.tell(`Can't decode the token`);
}
} else {
this.tell('There was an error.');
}
},
I’m not sure if that’s the recommended way of doing it, but it works
Hi, just wondering if you had a chance to look at this. I just recently installed Jovo and this is my first issue encountered while migrating my current code. Thanks in advance.
I missed that one.
I will publish an update (beginning of next week) that returns the following object:
this.$googleAction.$user.getGoogleProfile()
export interface GoogleAccountProfile {
email: string;
email_verified: boolean;
name: string;
picture: string;
given_name: string;
family_name: string;
[key: string]: string | boolean;
}
thanks @MarekMis. I took the relevant part from your snippet.