将自定义身份验证提供程序与 Firebase 相关联 [英] Linking custom auth provider with Firebase

查看:38
本文介绍了将自定义身份验证提供程序与 Firebase 相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到使用 Firebase 我可以允许用户通过将身份验证提供程序凭据链接到现有用户帐户来使用多个身份验证提供程序登录我的应用程序.是否可以链接自定义身份验证提供程序,例如 Linkedin?我读到我需要将 AuthCredential 对象传递给登录用户的 linkWithCredential 方法,但我没有找到自定义 AuthCredential.

I read that with Firebase I can allow users to sign in to my app using multiple authentication providers by linking auth provider credentials to an existing user account. Is possible linking custom auth provider such as Linkedin? I read that I need to pass the AuthCredential object to the signed-in user's linkWithCredential method but I don't find a custom AuthCredential.

推荐答案

将不受支持的提供者自定义令牌链接到现有帐户的一种方法是获取 Firebase 帐户的用户 ID 和不受支持的提供者用户 ID 并保存哈希映射接受不受支持的提供者 ID 并返回您要链接到的 firebase uid.当用户使用自定义令牌登录到不受支持的提供程序时,您会从地图中获取相应的 firebase uid 并返回带有该 uid 的自定义令牌,该 uid 在 signInWithCustomToken 上与原始 firebase 用户解析.

One way to link an unsupported provider custom token to an existing account is to get the Firebase account's user id and the unsupported provider user id and save a hash map that takes in the unsupported provider id and returns the firebase uid which you want to link to. When the user signs in to unsupported provider with custom token, you get the corresponding firebase uid from the map and return a custom token with that uid which on signInWithCustomToken resolves with the original firebase user.

缺点是您在用户的提供者数据列表中看不到不受支持的提供者.您还需要存储地图.

The downside is that you don't see the unsupported provider in the list of provider data within the user. You also need to store the map.

这篇关于将自定义身份验证提供程序与 Firebase 相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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