admin管理员组

文章数量:1332107

I am trying to make the new google one tap sign in work following this guide:

When I call :

const hintPromise = googleyolo.hint({
  supportedAuthMethods: [
    ""
  ],
  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: "",
      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: "",
  displayName: "testName",
  id: "[email protected]"
}

Has anyone managed to get this to work?

I am trying to make the new google one tap sign in work following this guide:

https://developers.google./identity/one-tap/web/get-started

When I call :

const hintPromise = googleyolo.hint({
  supportedAuthMethods: [
    "https://accounts.google."
  ],
  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.",
      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.",
  displayName: "testName",
  id: "[email protected]"
}

Has anyone managed to get this to work?

Share edited Oct 28, 2017 at 1:55 Steven 3,88024 silver badges39 bronze badges asked Oct 27, 2017 at 14:30 d--bd--b 5,7793 gold badges45 silver badges72 bronze badges 1
  • 1 Hmm, is the domain you're running the code on registered in the developer console for the client ID that you are using? (looks like you are try on localhost:3000 ?) If you send me your client ID, I can take a look -- [email protected] – Steven Commented Oct 28, 2017 at 1:01
Add a ment  | 

2 Answers 2

Reset to default 9

I had the same issue, but was able to resolve it by adding the correct "Authorized JavaScript origins" at https://console.developers.google./ 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./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]

本文标签: javascriptGoogle one tap signin does not return idTokenStack Overflow