reactjs-React和firebase,如何使用google登录进行身份验证
发布时间:2022-03-28 16:48:27 562
相关标签: # html# react-native
这个问题以前在堆栈溢出时被问过,但是,随着代码的更改,所有答案似乎都不起作用。
以下是我找到并尝试过的一些:React Firebase使用谷歌登录 开发者_错误代码10-Firebase google登录react native
这两个错误总是一样的。要么我无法导入所需的模块,因为它不存在,要么我正在调用一个不存在的方法。
以下是我当前使用常规电子邮件登录的代码:
export function Login() {
const [loading, setLoading] = useState(false);
const {authStore } = useContext(StoreContext);
const firestore = firebase.firestore();
const provider = new firebase.auth.GoogleAuthProvider();
const signInWithGoogle = () => auth.signInWithPopup(provider);
const formik = useFormik({
initialValues,
validationSchema: loginSchema,
onSubmit: (values, { setStatus, setSubmitting }) => {
setLoading(true);
setTimeout(() => {
console.log("logging in")
signInWithGoogle();
signInWithEmailAndPassword(auth, values.email, values.password)
.then((userCredential) => {
// Signed in
console.log(userCredential.user);
setLoading(false);
setStatus("");
authStore.authenticate();
})
.catch((error) => {
console.log(error.code);
console.log(error.message);
setLoading(false);
setSubmitting(false);
setStatus("The login detail is incorrect");
});
setLoading(false);
setSubmitting(false);
}, 1000);
},
});
使用谷歌功能登录不起作用。
谢谢,如果您有任何关于这方面文档的建议或建议,我们将不胜感激。
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报