未找到身份提供者配置
当我尝试使用FacebookAuthProvider验证到Firebase时出现此错误。我正在使用react-native-fbsdk与react-native进行Facebook身份验证集成。我的目的是使用身份验证令牌登录用户ti firebase并将用户数据记录在firestore中的USERS集合中。
下面是我的代码。感谢您的帮助。
fbAuth(){
LoginManager.logInWithReadPermissions(['public_profile','email','user_photos']).then(
(result)=>{
this.handleCallBack(result),
function(error){
console.log("error in facebook login.");
}
}
);
}
handleCallBack(result){
var _this = this;
if(result.isCancelled){
console.log("facebook login cancelled.");
}else{
AccessToken.getCurrentAccessToken().then(
(data) => {
const token = data.accessToken;
fetch('https://graph.facebook.com/v2.8/me?fields=id,first_name,last_name,gender,birthday&access_token=' + token)
.then((response=>response.json()))
.then((json)=>{
const imageSize = 120;
const facebookID = json.id;
const fbImage = "https://graph.facebook.com/${facebookID}/picture?height=${imageSize}";
})
this.authenticate(data.accessToken)
.then(result =>{
const {uid} = result;
_this.createUser(uid,json,token,fbImage);
})
})
.catch(error=>{
console.log(error);
})
}
}
authenticate = (token) => {
const provider = firebase.auth.FacebookAuthProvider;
const credential = provider.credential(token);
var ret = firebase.auth().signInWithCredential(credential);
return ret;
}
createUser = (uid,userData,token,dp) => {
const defaults = {
uid,
token,
dp,
ageRange: [20, 30]
}
const db = firebase.firestore();
db.settings({timestampsInSnapshots:true});
db.collection('USERS').add({
...userData, ...defaults,
fsTimestamp: firebase.firestore.Timestamp.now()
})
.then(()=>{
console.log("User recorded.");
//this.clearState();
})
.catch((error)=>{console.log(error)});
}
这是我的进口货
import * as firebase from 'firebase';
import 'firebase/firestore';
import {LoginManager,LoginButton,AccessToken,GraphRequest,GraphRequestManager} from 'react-native-fbsdk';