使用带Firebase的OAuth问题通过Facebook登录(input_token中的App_id与Viewing App不匹配) [英] Login through Facebook using OAuth issue with Firebase (App_id in the input_token did not match the Viewing App)

查看:468
本文介绍了使用带Firebase的OAuth问题通过Facebook登录(input_token中的App_id与Viewing App不匹配)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Facebook登录,通过OAuth收集一些数据,然后使用该凭据登录到Firebase.但是,我遇到了一个问题(请参阅下面的日志).

I am trying to login through Facebook, collect some data over OAuth and then login to Firebase using the credential. I am however encountering an issue (please see logs below).

代码示例

@objc func signInWFB() {

    let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()

    fbLoginManager.logIn(withReadPermissions: ["email","user_birthday","user_gender"], from: self) { (result, error) -> Void in

        if (error == nil) {
            let fbloginresult : FBSDKLoginManagerLoginResult = result!
            if (result?.isCancelled)! {
                print(result ?? FBSDKLoginManagerLoginResult())
            } else if(fbloginresult.grantedPermissions.contains("email")) {
                if((FBSDKAccessToken.current()) != nil) {
                    FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, email, birthday, gender"]).start( completionHandler: { (connection, result, error) -> Void in
                        if (error == nil) {
                            //everything works print the user data
                            print(result ?? AnyObject.self)

                            if let d = result as? [String:Any] {

                                // ALL GOOD UP TO HERE

                                let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current()!.tokenString)

                                Auth.auth().signIn(with: credential) { (authResult, error) in
                                    if let error = error {
                                        print(error) // ERROR HERE
                                        return
                                    }

                                    // ...
                                }
                            }
                        }
                    })
                }
            }
        }
    }
}

日志

错误域= FIRAuthErrorDomain代码= 17004不成功的debug_token 来自Facebook的回复:{错误":{消息":"(#100) input_token与观看不匹配 App," type:" OAuthException," code:100," fbtrace_id:" BwV3jZweRqo}}" UserInfo = {NSLocalizedDescription =不成功的debug_token响应 来自Facebook:{错误":{消息":(#100) input_token与观看不匹配 App," type:" OAuthException," code:100," fbtrace_id:" BwV3jZweRqo}}, error_name = ERROR_INVALID_CREDENTIAL}

Error Domain=FIRAuthErrorDomain Code=17004 "Unsuccessful debug_token response from Facebook: {"error":{"message":"(#100) The App_id in the input_token did not match the Viewing App","type":"OAuthException","code":100,"fbtrace_id":"BwV3jZweRqo"}}" UserInfo={NSLocalizedDescription=Unsuccessful debug_token response from Facebook: {"error":{"message":"(#100) The App_id in the input_token did not match the Viewing App","type":"OAuthException","code":100,"fbtrace_id":"BwV3jZweRqo"}}, error_name=ERROR_INVALID_CREDENTIAL}

我尝试过的内容

  1. 信息列表具有正确的FacebookAppID和AccountKitClientToken
  2. 在Facebook设置中尝试对要求应用秘密"进行开启/关闭操作
  3. 从Firebase的OAuth重定向URI已添加到Facebook设置

推荐答案

这很难找到.我必须转到Firebase>身份验证>登录方法> Facebook,然后更改其中的字段以匹配Facebook开发人员上的字段.由于某些莫名其妙的原因,他们与众不同...

This was ridiculously hard to find. I had to go to Firebase > Authentication > Sign-in Method > Facebook and change the fields in there to match those on Facebook developer. For some inexplicable reason they were different...

这篇关于使用带Firebase的OAuth问题通过Facebook登录(input_token中的App_id与Viewing App不匹配)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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