android - 使用 twitter 登录 Firebase 在 React Native 中不起作用
问题描述
我正在尝试在反应本机应用程序的 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”}
我怎样才能解决这个问题。
注意:-我使用相同的方法登录谷歌并且工作正常
解决方案
我找到了。我正在使用 const
凭证 = firebase.auth.GoogleAuthProvider.credential(loginData.authToken, loginData.authTokenSecret)
安装的
const credential = firebase.auth.TwitterAuthProvider.credential(loginData.authToken, loginData.authTokenSecret)
推荐阅读
- php - fopen(C:\wamp64\www\jarian\public):无法打开流:权限被拒绝 Windows 10 Wamp
- javascript - 我想在 Vuex 之间共享价值观
- javascript - 如何访问每个数组中的元素?
- reactjs - 将表单值发送到服务器的正确方法 - React
- python-3.x - 显示特定月份的所有日期以获取数据
- python - Python网络爬取错误:将数据传输到数据库
- c++ - 在c ++中暂停执行的最快方法是什么
- python - 始终在框架中测量没有参考对象的对象大小
- vue.js - 我的 Nuxt Storyblok 项目返回错误
- matrix - 如何使用 MAGMA 和 NVIDIA GPU 卡而不是 CPU LAPACKE 来逆大矩阵