I am trying to make the new google one tap sign in work following this guide:
https://developers.google.com/identity/one-tap/web/get-started
When I call :
const hintPromise = googleyolo.hint({
supportedAuthMethods: [
"https://accounts.google.com"
],
supportedIdTokenProviders: [
// Google can provide ID tokens -- signed assertions of a user's
// identity -- which you can use to create more streamlined sign-in
// and sign-up experiences.
{
uri: "https://accounts.google.com",
clientId: "YOUR_GOOGLE_CLIENT_ID"
}
]
});
I get a response in the promise callback, with no error. But the idToken is empty...
hintPromise.then((credential) => {
if (credential.idToken) { // <= THIS IS ALWAYS FALSE!!!
// Send the token to your auth backend.
loginWithGoogleIdToken(credential.idToken);
}
}, (error) => { console.log(error); });
the credential
object looks like this:
{
authDomain: "http://localhost:3000",
authMethod: "https://accounts.google.com",
displayName: "testName",
id: "[email protected]"
}
Has anyone managed to get this to work?
I had the same issue, but was able to resolve it by adding the correct "Authorized JavaScript origins" at https://console.developers.google.com/ for my project. I needed to include the URI including the port "http://localhost:3000" rather than just "http://localhost".
From the google page - "If you're using a nonstandard port, you must include it in the origin URI."
We just published some troubleshooting guidance: https://developers.google.com/identity/one-tap/web/troubleshooting
The most important things to check are the following:
make sure that you supply a Google client ID in any requests and that the domain you are running the code is an authorized origin, including the port. See documentation for details
ensure that you have an active Google Account and that the Smart Lock feature is enabled. Try with a regular gmail account with default settings
check that you are using a supported user-agent. Importantly, the iOS emulation modes in Chrome Dev Tools are out-of-date (fix pending)
If you still cannot get it working, or have any feedback at all, we'd love to hear from you: reach out to [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With