如何在Firebase 3.0中的应用之间共享身份验证令牌? [英] How to share Authentication token between app in Firebase 3.0?

查看:40
本文介绍了如何在Firebase 3.0中的应用之间共享身份验证令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧版的Firebase中,我们可以获取经过身份验证的令牌,以在我们的应用程序扩展之间共享.

In older version of Firebase we can obtain authenticated token for sharing between our app, extensions.

但是当升级到Firebase 3.0时,该功能不再起作用.我在FIRUser上使用了getTokenWithCompletion :,然后在我的应用程序扩展中,我刚刚获得的令牌中调用了signInWithCustomToken:completion:.但是Firebase会返回错误消息:

But when upgrade to Firebase 3.0, that function doesn't work anymore. I've use getTokenWithCompletion: on FIRUser, then in my App Extension I call signInWithCustomToken:completion: with token i just obtained. But Firebase return an error with messgage:

Error Domain = FIRAuthErrorDomain代码= 17000自定义令牌格式为不正确.请检查文档."UserInfo = 0x799b6010{error_name = ERROR_INVALID_CUSTOM_TOKEN,NSLocalizedDescription =自定义令牌格式不正确.请检查文档.}

Error Domain=FIRAuthErrorDomain Code=17000 "The custom token format is incorrect. Please check the documentation." UserInfo=0x799b6010 {error_name=ERROR_INVALID_CUSTOM_TOKEN, NSLocalizedDescription=The custom token format is incorrect. Please check the documentation.}

如何从FIRUser获取身份验证令牌以在我的App Extension中重新对其进行身份验证?

How to get authenticate token from FIRUser to re-authenticate it in my App Extension?

推荐答案

signInWithCustomToken 旨在与在您自己的服务器上铸造的您自己的令牌一起使用(了解更多

signInWithCustomToken is meant to be used with your own tokens minted on your own server (read more here).

在应用程序的不同组件之间引导会话的最佳方法是在登录时共享用户的凭据,并对所有组件执行引导.

The best way for you to bootstrap a session between different components of your application will be to, at sign-in time, share the user's credential and perform the bootstraping across all your components.

例如,如果您使用的是 Facebook登录名,当您检索Facebook访问令牌时,您必须将其从您的应用程序共享到扩展程序,然后在主应用程序和扩展程序中使用相同的令牌调用signInWithCredential.

For example, if you are using Facebook login, when your retrieve the facebook access token, you would have to share it from your app to your extension, and then call signInWithCredential with the same token in both your main app and extension.

当前无法使用另一个Firebase应用程序实例中的v3.X SDK将用户登录到Firebase应用程序.

There is currently no way to sign in a user into a Firebase app with the v3.X SDKs from another Firebase app instance.

这篇关于如何在Firebase 3.0中的应用之间共享身份验证令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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