简体   繁体   English

linkWithCredential 和 linkWithPopup 有什么区别

[英]What's the difference with linkWithCredential and linkWithPopup

I read the Convert an anonymous account to a permanent account and see that using the:我阅读了将匿名帐户转换为永久帐户,并看到使用:

auth.currentUser.linkWithCredential(credential)

will merge the anonymous and eg, Google, Facebook etc.. credential将合并匿名凭证和例如 Google、Facebook 等credential

Then I read Link Multiple Auth Providers to an Account Using JavaScript will do the same using the:然后我阅读了使用 JavaScript 将多个 Auth Providers 链接到一个帐户将使用以下方法执行相同的操作:

auth.currentUser.linkWithPopup(provider)

What is the difference and which should I use if my SPA Reactjs app require anonymous sign and later if user want to sign in he can do that with Google, Facebook..如果我的 SPA Reactjs 应用程序需要匿名登录,之后有什么区别,我应该使用哪个,如果用户想登录,他可以使用 Google Facebook 来登录。

I run some test and see that using linkWithPopup return error auth/credential-already-in-use if the Account exist so then I must use signInWithCredential .我运行了一些测试,发现如果帐户存在,使用linkWithPopup返回错误auth/credential-already-in-use那么我必须使用signInWithCredential This works ok however so far.到目前为止,这工作正常。

Reading about linkWithCredential I don't see what to do if the Google account is already in use at Firebase. That linkWithCredential would create two account I don't think so I must maybe do what I did with linkWithPopup like signInWithCredential阅读有关linkWithCredential的信息,如果 Google 帐户已在 Firebase 使用,我不知道该怎么办。我认为linkWithCredential会创建两个帐户,所以我可能必须做我对linkWithPopup所做的事情,比如signInWithCredential

This two does the same thing in the end;这两个最终做同样的事情; when to use what, or what did I miss?什么时候使用什么,或者我错过了什么?

linkWithCredential() links the account with credentials that you obtained from a previous sign-in. linkWithCredential()将该帐户与您从先前登录中获得的凭据相关联。

linkWithPopup() links the account with the given provider, guiding the user through the authentication flow for that provider. linkWithPopup()将帐户与给定的提供商链接,引导用户完成该提供商的身份验证流程。 The credentials will be automatically obtained from that sign-in.凭据将自动从该登录中获取。

So, if you already have credentials for an account where the user already signed in, use linkWithCredential .因此,如果您已经拥有用户已登录的帐户的凭据,请使用linkWithCredential If you don't have user credentials, and you need to user to go through a sign-in flow to get them, use linkWithPopup() .如果您没有用户凭据,并且需要通过登录流程使用 go 来获取它们,请使用linkWithPopup()

The end result is the same in either case - the Firebase Auth account for the currently signed in will be linked to the other account (Google, Facebook, etc) where the user has proved their identity.无论哪种情况,最终结果都是相同的 - 当前登录的 Firebase Auth 帐户将链接到用户已证明其身份的另一个帐户(Google、Facebook 等)。

linkWithPopup() is necessary for linking accounts on Flutter Web when the social auth would require a pop up.当社交身份验证需要弹出窗口时, linkWithPopup()对于链接 Flutter Web 上的帐户是必需的。 For instance, if you are needing to link an Apple account to an existing account, signInWithPopup() would authenticate, create a new firebase account and return the new user...which you don't want for an existing account.例如,如果您需要将 Apple 帐户链接到现有帐户, signInWithPopup()将进行身份验证,创建一个新的 firebase 帐户并返回新用户......您不希望现有帐户出现。

With linkWithPopup() , you would authenticate the apple user and link, skipping the new account creation and return user steps.使用linkWithPopup() ,您可以验证 apple 用户和链接,跳过创建新帐户和返回用户的步骤。

If you use signInWithPopup() in conjunction with linkWithCredential() , you'll never reach linkWithCredential() in most cases (the user returns and rebuilds the app) or you'll just error on the link attempt because a new account had been created.如果将signInWithPopup()linkWithCredential()结合使用,则在大多数情况下(用户返回并重建应用程序)您将永远无法访问linkWithCredential() ,或者您只会在链接尝试时出错,因为已创建新帐户.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 linkWithCredential 和 Flutter Web 与 Apple - linkWithCredential and Flutter Web with Apple Firebase AngularFireAuth 和 Auth 有什么区别? - What's the difference between Firebase AngularFireAuth and Auth? MessageAttributeValue 和 MessageSystemAttributeValue 有什么区别 - What's the difference between MessageAttributeValue and MessageSystemAttributeValue timestamp[ns] timestamp[s] 有什么区别? - What is difference between timestamp[ns] timestamp[s]? Kube.netes 和 Kube.netes Engine 有什么区别? - What's the difference between Kubernetes and Kubernetes Engine? 在 linkWithCredential() 上触发 Firebase 云函数 - Trigger Firebase Cloud Function on linkWithCredential() Cloud Firestore 和 Firebase 实时数据库有什么区别? - What's the difference between Cloud Firestore and the Firebase Realtime Database? Go 中的数据竞争和条件有什么区别? - What's the difference between Data Race and Condition in Go? buildspec、appspec 和滚动我自己的 AMI 之间有什么区别? - What's the difference between buildspec, appspec, and rolling my own AMI? 常规和 ml AWS EC2 实例有什么区别? - What's the difference between regular and ml AWS EC2 instances?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM