如何将多个验证提供商链接到Firebase帐户? [英] How to Link Multiple Auth Providers to an Firebase Account?
问题描述
我无法成功执行,我按照Firebase文档的说明按照以下步骤操作:
I am unable to to sucessfully to do , I followed the following steps as instructed on Firebase Docs:
- 使用现有的登录auth提供者(我的案例:Facebook )
- 完成新认证提供商的登录流程,直到,但不包括,调用其中一个
Auth.signInWith
方法(我的情况:我想链接电子邮件和密码和Google OAUth )。所以这是我不清楚的一步,我使用var provider = new firebase.auth.GoogleAuthProvider();
创建了一个新的提供程序,我没有执行Firebase.auth()。signInWithPopup(provider)
。 - 然后为了获得google的authcredential,我运行
var credential = firebase.auth.GoogleAuthProvider.credential(
(我得到一个未定义的googleUser错误)这个错误似乎是合适的,因为我没有登录使用Google Outh,但这是第二个步骤说明(不登录)
googleUser.getAuthResponse()。id_token); - 然后,此命令链接到Facebook提供商
auth.currentUser.link(凭证)上的当前用户
- Signed in use using existing auth provider(my case:facebook).
- Complete the sign-in flow for the new authentication provider up to, but not including, calling one of the
Auth.signInWith
methods.(my case: i want to link email & password and Google OAUth). So this is the step i'm unclear about, I created a new provider usingvar provider = new firebase.auth.GoogleAuthProvider();
and I did not doFirebase.auth().signInWithPopup(provider)
. - Then to get authcredential for google I run
var credential = firebase.auth.GoogleAuthProvider.credential( googleUser.getAuthResponse().id_token);
(I get an undefined googleUser error) this error seems appropriate since I have not signed in using Google Oauth but thats what the 2nd steps states(not to signin) - And then this command to link with the current user who is on a Facebook Provider
auth.currentUser.link(credential)
我的理解是,currentUser需要链接到我现有的提供商(Facebook)。似乎谷歌的凭据变量从来没有计算过。任何具有功能代码示例的人都会真的有帮助。
My understanding is that currentUser needs to be linked to my existing Provider(Facebook). It seems that credential variable for google is never computed. Anyone with a functional code example would really help.
推荐答案
如果您要手动将google和电子邮件/通行证帐户链接到现有的只有Facebook的firebase用户,以下:
首先用户应该登录到Facebook。
链接google用户:
If you want to manually link a google and email/pass account to an existing facebook only firebase user, you can do the following: First the user should be signed in to facebook. Link the google user:
var provider = new firebase.auth.GoogleAuthProvider();
auth.currentUser.linkWithPopup(provider);
然后链接电子邮件/通行证帐户:
Then link the email/pass account:
auth.currentUser.link(firebase.auth.EmailAuthProvider.credential(auth.currentUser.email, 'password'))
所有要链接的帐户必须是新的,而不是已经链接。
All these accounts to be linked must be new and not already linked.
这篇关于如何将多个验证提供商链接到Firebase帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!