javascript - 为什么我无法使用通过 firebase 从 facebook sdk 获得的凭据登录?
问题描述
嗨,我在使用 expo、facebook sdk 和 Firebase 登录 facebook 时出错
[Error: Unsuccessful debug_token response from Facebook: {"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190,"fbtrace_id":"AM5hHHrnXuN4ehHi4q_mmR_"}}]
在我的控制台日志中,我可以看到正在接收凭据,但我仍然收到此错误,并且在我的 facebook 通知中我收到了我登录到此应用程序的通知,错误在 firebase signInWithCredential 中,也在 facebook 调试器上:https://developers .facebook.com/tools/debug/accesstoken/来自凭证日志的令牌是有效的,我的代码
import React from 'react'
import firebase from "firebase/app";
import "firebase/auth";
import {Button} from "react-native-paper";
import * as Facebook from "expo-facebook";
function FacebookLogin({appColor}) {
firebase.auth().onAuthStateChanged(user => {
if (user != null && !user.isAnonymous) {
console.log('We are authenticated now!');
}
// Do other things
});
async function LoginWithFacebook() {
await Facebook.initializeAsync({appId: '741443520140189', appName: 'Just an app'});
const {type, token} = await Facebook.logInWithReadPermissionsAsync({
permissions: ['public_profile'],
});
if (type === "success") {
console.log("TOKEN", token)
const credential = firebase.auth.FacebookAuthProvider.credential(token);
console.log("credentials", credential)
firebase
.auth()
.signInWithCredential(credential)
.catch(error => {
console.log(error)
});
}
}
return <Button onPress={() => LoginWithFacebook()} color={"#fff"} style={{marginTop: "20%"}}>Login</Button>
}
export default FacebookLogin
解决方案
推荐阅读
- echarts - Apache Echart,如何使用用户定义的地图覆盖轴标签值
- asp.net-core-mvc - BCrypt PasswordHasher:- FormatException:输入不是有效的 Base-64 字符串
- python - ImportError:无法从“tensorflow.python.eager.context”导入名称“get_config”
- reactjs - 渲染父组件初始化子组件的状态
- flutter - 在 Flutter 中对未来列表进行排序
- tensorflow - 对象没有属性“visible_device_list”
- django - djanog模板循环中的分组条形数据集
- python - Tensorflow - autodiff 是否让我们从 back-prop 实现中解脱出来?
- python - 如何从 .whl 文件安装打开的 cv 包?
- flutter - Flutter web 的 Firebase 远程配置