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

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

问题描述

我通过Firebase阅读了该文档,可以允许用户通过将身份验证提供程序凭据链接到现有的用户帐户,使用多个身份验证提供程序登录到我的应用程序。有可能链接自定义auth提供商,如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并返回所需的Firebase用户ID链接到。当用户使用自定义标记登录到不受支持的提供程序时,将从地图获取相应的firebase uid,并返回一个自定义标记,该标记包含signInWithCustomToken与原始Firebase用户解析的uid。

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天全站免登陆