0

So, I am trying to implement Facebook oAuth in React. I have already created an app and provided the following permissionsMyApp's permissions

When I click on the Login via Facebook button, I get redirected to a blank page: Blank Page

https://www.facebook.com/v19.0/dialog/oauth?app_id={app_id}&cbt=1708623988568&channel_url=https%3A%2F%2Fstaticxx.facebook.com%2Fx%2Fconnect%2Fxd_arbiter%2F%3Fversion%3D46%23cb%3Df321eccf78467bd5a%26domain%3Dlocalhost%26is_canvas%3Dfalse%26origin%3Dhttp%253A%252F%252Flocalhost%253A3000%252Ffe2f7254840790489%26relation%3Dopener&client_id=1082613119655352&display=popup&domain=localhost&e2e=%7B%7D&fallback_redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F&locale=en_US&logger_id=f8d48aafad08478f2&origin=1&redirect_uri=https%3A%2F%2Fstaticxx.facebook.com%2Fx%2Fconnect%2Fxd_arbiter%2F%3Fversion%3D46%23cb%3Df91b0ff47a1eb9d27%26domain%3Dlocalhost%26is_canvas%3Dfalse%26origin%3Dhttp%253A%252F%252Flocalhost%253A3000%252Ffe2f7254840790489%26relation%3Dopener%26frame%3Df15b4e394597d51bd&response_type=token%2Csigned_request%2Cgraph_domain&scope=email&sdk=joey&version=v19.0

The link is something like above.

Here's my code:

index.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + React</title>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '1082613119655352',
          cookie     : true,
          xfbml      : true,
          version    : 'v19.0'
        });
          
        FB.AppEvents.logPageView();   
          
      };

      (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>

App.jsx

import React from 'react';
import { FacebookProvider, LoginButton } from 'react-facebook';

function App() {
    function handleSuccess(response) {
      console.log(response.status);
    }
  
    function handleError(error) {
      console.log(error);
    }
  
    return (
      <FacebookProvider appId="1082613119655352">
        <LoginButton
          scope="email"
          onError={handleError}
          onSuccess={handleSuccess}
        >
          Login via Facebook
        </LoginButton>
      </FacebookProvider>
  );
}

export default App;

There aren't any console errors either. Idk what's the issue. Please help.

1
  • Enable Web OAuth Login in your app settings.
    – CBroe
    Commented Feb 23 at 7:05

0