[英]Google gapi.auth2.getAuthInstance().isSignedIn().get() is always false when multiple google accounts
I am having a weird problem with google gapi auth.我在使用 google gapi auth 时遇到了一个奇怪的问题。 For some reason, the value for
gapi.auth2.getAuthInstance().isSignedIn().get()
is always returning false.由于某种原因,
gapi.auth2.getAuthInstance().isSignedIn().get()
的值总是返回 false。 This is my setup:这是我的设置:
gapi.load("auth2", initAuth2);
initAuth2(){
gapi.auth2.init({
client_id: "xxxxx-yyyyy.apps.googleusercontent.com",
hosted_domain: "domain.com",
redirect_uri: "http://localhost:4200",
ux_mode: "redirect",
}).then(performAuth, error=>{
console.error(`Error initiating gapi auth2: ${error.details}`);
});
}
performAuth(googleAuth){
const isSignedIn = googleAuth.isSignedIn.get();
if(!isSignedIn){
googleAuth.signIn();
return;
}
const user = googleAuth.currentUser.get();
console.log(user);
}
I have two google workspace accounts sign in the same chrome profile.我有两个 google 工作区帐户登录同一个 chrome 配置文件。 When I run this script, I get the prompt to select an account.
当我运行此脚本时,我收到 select 帐户的提示。 No matter which one I choose, the flow just keeps looping.
无论我选择哪一个,流程都在不断循环。 The reason for that is that the line
const isSignedIn = googleAuth.isSignedIn.get();
原因是
const isSignedIn = googleAuth.isSignedIn.get();
is always returning false.总是返回假。
Things I've tried so far:到目前为止我尝试过的事情:
If I change the init options from ux_mode: "redirect"
to ux_mode: "prompt"
.如果我将初始化选项从
ux_mode: "redirect"
更改为ux_mode: "prompt"
。 It works.有用。 However, that is not the desired experience.
然而,这并不是我们想要的体验。 Also, if I only have one google workspace in the chrome profile, it works.
此外,如果我在 chrome 配置文件中只有一个 google 工作区,它可以工作。 Even more interesting... if I use a client id from an older project... it works.
更有趣的是……如果我使用旧项目中的客户 ID……它可以工作。 The problem is that the consent screen shows the wrong app name.
问题是同意屏幕显示错误的应用名称。
I know this question is similar to this one , however I feel it's different because none of the above troubleshooting works.我知道这个问题与这个问题相似,但是我觉得它有所不同,因为上述故障排除都不起作用。 Any insights?
有什么见解吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.