Firebase 身份验证自定义令牌 iOS

Firebase auth custom token iOS

我正在尝试使用 Firebase SDK 添加到我的应用程序 VK 授权。

当用户授权完成后,我尝试将令牌传递给 Firebase。

func vkSdkAccessAuthorizationFinishedWithResult(result: VKAuthorizationResult!){

        let tokenString = result.token.description
        FIRAuth.auth()?.signInWithCustomToken(tokenString) { (user, error) in
            // ...

        }
    }

Error: [1] (null) "NSLocalizedDescription" : "The custom token format is incorrect. Please check the documentation."

我可以在没有 运行 服务器的情况下通过自定义身份验证使用 Firebase 吗?

来自 Firebase 文档。 Create custom tokens using the Firebase SDK,

我会说你需要为此使用 createCustomToken() 方法。你不能使用你的 VK 服务器令牌通过 firebase 登录......你需要使用 [=11= 为 firebase 生成令牌]方法。

 var uid = "some-uid";
 var customToken = firebase.auth().createCustomToken(uid);

希望这对你有用