使用 Firebase Google 用户身份验证更改用户 [英] Change user with Firebase Google user authentication

查看:28
本文介绍了使用 Firebase Google 用户身份验证更改用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Firebase Google 用户身份验证时,如果用户已经授权应用程序并且仅登录到一个 Google 帐户,则会立即登录.

When using Firebase Google user authentication the user is immediately logged in if they have already authorized the application and only logged in to one Google account.

有没有办法强制显示选择一个帐户"对话框,以便用户有机会登录不同的 Google 帐户或创建一个新帐户?

Is there a way to force the "Choose an account" dialog to appear so that the user has the opportunity to login to a different Google account or create a new one?

据我所知,用户必须从 Google.com 手动注销当前的 Google 帐户(或登录 > 1)才能显示该对话框.

Currency as far as I know the user has to manually logout of the current Google account (or login to > 1) from Google.com to make the dialog appear.

推荐答案

您可以强制选择带有 'prompt' provider 参数的帐户.

You can force to choose an account with 'prompt' provider parameter.

var googleAuthProvider = new firebase.auth.GoogleAuthProvider();
googleAuthProvider.setCustomParameters({
   prompt: 'select_account'
});
firebase.auth().signInWithRedirect(googleAuthProvider)

使用 Firebase JavaScript SDK v4.1.2 测试

Tested with Firebase JavaScript SDK v4.1.2

这篇关于使用 Firebase Google 用户身份验证更改用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆