首页 > 解决方案 > Facebook 授权不适用于 Firebase 身份验证

问题描述

我在我构建的聊天应用程序上进行了社交身份验证。Google auth 工作得非常好,但 Facebook auth 神秘地点击了另一个 URL,然后重定向回登录页面。我知道App idApp secret在 Facebook 的 firebase 身份验证中是正确的。当我只是在本地运行应用程序时http://localhost:3000,它给了我这个错误:在此处输入图像描述

我认为将它托管到一个安全站点https可以解决这种情况,但现在它只是点击 url 并返回登录页面,控制台中没有记录任何错误。下面是处理登录的代码:

import React from 'react';
import { GoogleOutlined, FacebookOutlined } from '@ant-design/icons';
import 'firebase/app';

import { auth } from '../firebase';
import firebase from 'firebase/app';

const Login = () => {
  return (
    <div id='login-page'>
      <div id='login-card'>
        <h2>Welcome to Unichat!</h2>
        <div
          className='login-button google'
          onClick={() =>
            auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider())
          }
        >
          <GoogleOutlined /> Sign In with Google
        </div>
        <br /> <br />
        <div
          className='login-button facebook'
          onClick={() =>
            auth.signInWithRedirect(new firebase.auth.FacebookAuthProvider())
          }
        >
          <FacebookOutlined /> Sign In with Facebook
        </div>
      </div>
    </div>
  );
};

export default Login;

这是测试 Facebook 登录的托管站点:https ://chatapplication.netlify.app

标签: firebasefirebase-authenticationfacebook-authentication

解决方案


推荐阅读