尝试使用Firebase登录Twitter时出现此错误。所以我看到你不能使用React Native重定向或弹出。我的代码在下面,然后有一些我认为应该实现的代码,它允许您使用凭证登录但不确定具体如何。
export function handleAuthWithFirebase () {
return function (dispatch, getState) {
dispatch(authenticating())
console.log('Loggin in')
twitterProvider;
firebase.auth().signInWithRedirect(twitterProvider);
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a the Twitter OAuth 1.0 Access Token and Secret.
// You can use these server side with your app's credentials to access the Twitter API.
var token = result.credential.accessToken;
var secret = result.credential.secret;
// ...
}
// The signed-in user info.
var user = result.user;
console.log(user);
// Get user info an set user in /users/ path
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
}
我看到我可以使用以下代码手动登录
var credential = firebase.auth.TwitterAuthProvider.credential(token,secret);
firebase.auth().signInWithCredential(credential).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
但我如何以及何时获得令牌和秘密?我想我对如何手动实施登录感到困惑。我保留了现有代码的哪一部分,我该删除什么?有没有人之前做过这个并且偶然有一个代码片段?或者可以指向我一个链接?谢谢!