简体   繁体   English

Firebase身份验证自定义令牌iOS

[英]Firebase auth custom token iOS

I am trying to add to my app VK authorization with Firebase SDK . 我正在尝试使用Firebase SDK添加到我的应用VK授权中。

When user authorization finished, I try to pass token to Firebase. 用户授权完成后,我尝试将令牌传递给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." 错误:[1](null)“NSLocalizedDescription”:“自定义令牌格式不正确。请检查文档。”

Can I use Firebase with custom auth without running server? 我可以在不运行服务器的情况下使用Firebase和自定义身份验证

From Firebase Doc. 来自Firebase Doc。 Create custom tokens using the Firebase SDK , 使用Firebase SDK创建自定义令牌

I would say that you need to use createCustomToken() method for this.. you can not use your VK servers token to signIn with firebase ... you need to generate token for firebase with createCustomToken() method. 我要说的是,你需要使用createCustomToken()方法这个..你不能使用你的服务器VK令牌签到随着火力......你需要生成与火力令牌createCustomToken()方法。

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

May this work for you 愿这对你有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM