我正在努力使新的谷歌一键标志在工作中遵循以下指南:
https://developers.google.com/identity/one-tap/web/get-started
当我打电话:
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"
}
]
});我在承诺回调中得到一个响应,没有错误。但idToken是空的。
hintPromise.then((credential) => {
if (credential.idToken) { // <= THIS IS ALWAYS FALSE!!!
// Send the token to your auth backend.
loginWithGoogleIdToken(credential.idToken);
}
}, (error) => { console.log(error); });credential对象如下所示:
{
authDomain: "http://localhost:3000",
authMethod: "https://accounts.google.com",
displayName: "testName",
id: "testEmail@gmail.com"
}有人想办法让这件事成功吗?
发布于 2017-10-29 10:25:31
我也有同样的问题,但通过在https://console.developers.google.com/上为我的项目添加正确的“授权的JavaScript源”来解决这个问题。我需要包含URI,包括端口"http://localhost:3000“,而不仅仅是"http://localhost”。
在google页面中--“如果使用的是非标准端口,则必须将其包含在源URI中。”
发布于 2017-11-01 01:54:46
我们刚刚发布了一些故障排除指南:https://developers.google.com/identity/one-tap/web/troubleshooting
要检查的最重要事项如下:
如果你仍然不能让它工作,或者有任何反馈,我们很想听到你的意见:联系sso@google.com
https://stackoverflow.com/questions/46977458
复制相似问题