在旧版本的 Firebase 中,我们可以获得经过身份验证的 token ,以便在我们的应用程序、扩展程序之间共享。
但是当升级到 Firebase 3.0 时,该功能不再起作用。
我已经在 FIRUser 上使用了 getTokenWithCompletion:,然后在我的 App Extension 中,我使用我刚刚获得的 token 调用了 signInWithCustomToken:completion: 。但 Firebase 返回一个带有消息的错误:
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 获取身份验证 token 以在我的应用程序扩展中重新对其进行身份验证?
最佳答案
signInWithCustomToken
旨在与在您自己的服务器上类型转换的您自己的 token 一起使用(阅读更多 here)。
在应用程序的不同组件之间引导 session 的最佳方式是在登录时共享用户的凭据并在所有组件之间执行引导。
例如,如果您使用 Facebook login ,当您检索 facebook 访问 token 时,您必须将它从您的应用程序共享到您的扩展程序,然后在主应用程序和扩展程序中使用相同的 token 调用 signInWithCredential。
目前无法使用来自另一个 Firebase 应用实例的 v3.X SDK 将用户登录到 Firebase 应用。
关于firebase - 如何在 Firebase 3.0 中的应用程序之间共享身份验证 token ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37337714/