Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native and Parse.FacebookUtils

I'd like to sign users into my React-Native app using Parse and Facebook but it seems like the Facebook JS SDK is dependent on the dom. How can I sign in a user with facebook?

I'm currently using https://github.com/magus/react-native-facebook-login to log the user in natively, so I have access to their auth token, ect. But can't use the Parse.FacebookUtils.login() without the FB JS SDK.

like image 307
Tarrence Avatar asked Nov 28 '25 01:11

Tarrence


2 Answers

If you have your authData from the native FB SDK, you can bypass the FacebookUtils.init() call entirely. This should log in to a Parse user with FB:

Parse.User._logInWith('facebook', {
  authData: {
    id: FB_USER_ID,
    access_token: USER_ACCESS_TOKEN,
    expiration_date: TOKEN_EXPIRATION_DATE
  }
});

This'll return a Promise, same as Parse.FacebookUtils.logIn()

like image 143
Andrew I Avatar answered Nov 30 '25 20:11

Andrew I


I managed to get around this by commenting out the references to FB in the Parse SDK Parse.FacebookUtils.logIn flow and removing the safety checks. The FB SDK isn't actually needed to authenticate a user with Parse if you already have the authData object.

Obviously not an ideal solution, so leaving this open

like image 30
Tarrence Avatar answered Nov 30 '25 20:11

Tarrence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!