Teja
Teja

Reputation: 37

Getting Error While doing login with facebook and LinkedIn in reactjs

I'm implementing login with facebook and LinkedIn using React.js. getting below error's unable to resolve this. used below packages react-facebook-login and react-linkedin-login-oauth2

import React from 'react';
import { useLinkedIn } from "react-linkedin-login-oauth2";
import linkedin from "react-linkedin-login-oauth2/assets/linkedin.png";
import FacebookLogin from 'react-facebook-login/dist/facebook-login-render-props';

const FaceBookLoginProvider = () => {
    const responseFacebook = (response) => {
        console.log(response);
    };

    return (
        <FacebookLogin
            appId="498310359268039"
            autoLoad={true}
            fields="name,email,picture"
            callback={responseFacebook}
        />
    );
}
function LinkedInLoginProvider() {
    const { linkedInLogin } = useLinkedIn({
        clientId: '86wj5ppsvt1dzo',
        redirectUri: 'http://localhost:3000/linkedin',
        onSuccess: (code) => {
            console.log(code);
        },
        onError: (error) => {
            console.log(error);
        },
    });
    return (
        <>
            <img
                src={linkedin}
                alt="Log in with Linked In"
                style={{ maxWidth: '180px' }}
                onClick={linkedInLogin}
            />
        </>
    );
}

export { FaceBookLoginProvider, LinkedInLoginProvider }

Imported in the App.js file:

function App() {
  return (
    <>
    <FaceBookLoginProvider />
    <LinkedInLoginProvider />
    </>
  );
}
export default App;

I'm using below react version, and package related details:

react version is ^18.2.0. react-facebook-login: "^4.1.1", react-linkedin-login-oauth2: "^2.0.1".

While clicking on the facebook button, getting below errors:

in .env file given HTTPS=true.

Below facebook error is coming on page load also, even without clicking on facebook button.

After clicking on the facebook button. in UI we are getting below runtime error

in console we are getting bellow error:

after clicking on the facebook button along with above error in UI, in console we got this error

For, linkedIn getting below error in the pop-up:

on linkedin button click

Below are the steps followed to create app and appid:

  1. created facebook account - https://developers.facebook.com/
  2. selected developer option.
  3. while creating app selected, other option and selecting consumer.
  4. did setup, facebook login and given site URL - http://localhost/
  5. in app setting in basic gave app domain as - localhost

Below are the steps followed to create app and clientid in linkedIn:

  1. created developer linkedin account and got it verified.
  2. in products enabled - Sign In with LinkedIn using OpenID Connect
  3. in auth Authorized redirect URLs for your app given - http://localhost:3000

Upvotes: 0

Views: 84

Answers (0)

Related Questions