新的Firebase auth API不会登录我的Twitter用户

Dan*_*rwe 9 firebase firebase-authentication

我的应用程序之前正在验证用户,然后我为twitter实现了新的auth代码:

    vc.twitterLogin = { session, error in
        if let session = session {
            let credential = FIRTwitterAuthProvider.credentialWithToken(session.authToken, secret: session.authTokenSecret)
            FIRAuth.auth()?.signInWithCredential(credential) { [unowned self] user, error in
                if let error = error {
                    print(error.userInfo["NSUnderlyingError"])
                }
                if user != nil {
                    self.navCtrl.popViewControllerAnimated(true)
                    self.delegate?.didAuthenticate(self)
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

twitter身份验证工作正常,因为您可以看到它正在执行FIRAuth块.有任何想法吗?

这是错误:

可选(错误域= FIRAuthInternalErrorDomain代码= 3"(null)"UserInfo = {FIRAuthErrorUserInfoDeserializedResponseKey = {type = immutable dict,count = 3,entries => 0:{contents ="message"} = {contents ="未能成功来自Twitter的verify_credentials响应:{"errors":[{"code":32,"message":"无法验证您."}]}"} 1:errors = {type = immutable,count = 1,values =( 0:{type = immutable dict,count = 3,entries => 0:reason = invalid 1:message = {contents ="无法从Twitter获得成功verify_credentials响应:{"errors":[{"code":32, "消息":"无法对您进行身份验证."}]}"} 2:domain = global}

)}}:code = {value = + 400,type = kCFNumberSInt64Type}}})

小智 16

您需要在新界面(Auth - >登录方法 - > Twitter)中将Firebase Twitter API密钥更新为Fabric.io为您提供的自动生成的密钥.这些可在Fabric.IO界面中找到.

我的猜测是你让Fabric.IO自动为你的Twitter API生成新密钥,并在Info.plist中使用新的自定义Fabric.IO条目,但尚未在Firebase上更改它们.更新这些条目为我解决了问题.