Firebase使用Twitter登录不使用React native

问题描述 投票:1回答:1

我试图在反应原生应用程序上使用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)
            })

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

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

我怎样才能解决这个问题。

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

android firebase react-native twitter firebase-authentication
1个回答
0
投票

我找到了。我正在使用const

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

代替

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

© www.soinside.com 2019 - 2024. All rights reserved.