使用Twitter登录Firebase不能在React native中运行

时间:2019-03-19 10:43:31

标签: android firebase react-native twitter firebase-authentication

我正在尝试在React本机应用程序的Frebase身份验证中使用twitter。我正在使用以下代码来实现

      const { RNTwitterSignIn } = NativeModules;

      RNTwitterSignIn.init(TwitterKeys.TWITTER_CONSUMER_KEY, TwitterKeys.TWITTER_CONSUMER_SECRET)

          RNTwitterSignIn.logIn()
            .then(loginData => {
              console.log("loginData="+loginData.authToken + " "+ loginData.authTokenSecret)
              console.log(JSON.stringify(loginData));
              const credential = firebase.auth.GoogleAuthProvider.credential(loginData.authToken, loginData.authTokenSecret)

              return firebase.auth().signInWithCredential(credential);

            }).then((currentUser)=>{
              this.props.navigation.navigate('FlyerListing')

              //--------------------------Async Test--------------------------
                AsyncStorage.setItem("user", currentUser.uid)
                console.log("AsyncStorage= "+ currentUser.uid)
            //--------------------------------------------------------------
            })
            .catch(error => {
              console.log(error)
            })

当我尝试登录时,在控制台中出现以下错误:-

  

{代码:“ auth / invalid-credential”,消息:“无法解析Google   id_token:150550928-ZJgBitL44wrST6DKCWhUx9b2dmNo10RGyQZ“}

我该如何解决。

  

注意:-我正在使用相同的方法登录google及其Google   工作正常

1 个答案:

答案 0 :(得分:0)

我找到了。我正在使用const

  

凭证=   firebase.auth.GoogleAuthProvider.credential(loginData.authToken,   loginData.authTokenSecret)

安装

  

const凭证=   firebase.auth.TwitterAuthProvider.credential(loginData.authToken,   loginData.authTokenSecret)

相关问题