3

I want to implement facebook login my React native app. I am using react-native-fbsdk-next in React native for getting access token.

I want to authorize it from our Backend to register it in our DB. I tried but couldn't find any way to implement it. I saw passport-facebook also but didn't get how to use it with react native.

I just want that I will send token that I get from fb login to backend(Node js) and it will verify it. This approach worked for me in google sign in but I am unable to find anything for Facebook login.

Any kind of help will be appreciated. Thank you

Bhaskar Joshi
  • 413
  • 7
  • 18

1 Answers1

2

just check the token you received from the app login by running it with axios or fetch on the follwing url

https://graph.facebook.com/me?access_token=${accessToken}

Below is a sample axios function (middleware)

exports.checkFacebookToken = async (accessToken) => {
  try {
    const check = await axios.get(
      `https://graph.facebook.com/me?access_token=${accessToken}`
    );
    console.log(check);
    return true;
  } catch (error) {
    console.log(error.response.data.error.message);
    return false;
  }
};

More details on other social networks on this answer iOS & node.js: how to verify passed access token?

Mohamed Daher
  • 609
  • 1
  • 10
  • 23