Facebook login in react-native & firebase 3.1

2,161 views
Skip to first unread message

רועי נגר

unread,
Jul 4, 2016, 11:16:58 AM7/4/16
to Firebase Google Group

Hi guys, so I was trying firebase 3.1 facebook authentication with react-native.
Since firebase doesn't support popup or redirect in react-native, i'm using react-native-fbsdk to get the access token but when I'm trying to use auth.signInWithCredential, the sign in fail on


code: "auth/app-not-authorized",

message: "This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console."


This is my code. any help would be very much appreciated.


import { LoginManager, AccessToken} from 'react-native-fbsdk';
import firebase from '../Services/firebase'; const auth = firebase.auth();
const provider = firebase.auth.FacebookAuthProvider;
LoginManager.logInWithReadPermissions(['public_profile'])
.then(loginResult => {
if (loginResult.isCancelled) {
console.log('user canceled');
return;
}
AccessToken.getCurrentAccessToken()
.then(accessTokenData => {
const credential = provider.credential(accessTokenData.accessToken);
return auth.signInWithCredential(credential);
})
.then(credData => {
console.log(credData);
})
.catch(err => {
console.log(err);
});
});

Bassam

unread,
Jul 4, 2016, 6:27:22 PM7/4/16
to Firebase Google Group
Hey there,
I suspect the api key you are using has some issue or you are using the incorrect one for some reason.

Prabhaav Bhardwaj

unread,
Jul 19, 2016, 6:55:20 PM7/19/16
to Firebase Google Group
Hey,

Make sure you've given FB the proper OAuth redirect URI as described here: https://firebase.google.com/docs/auth/web/facebook-login

I used the same logic as you have in your code and it worked for me. As Bassam mentioned check your api keys too.


On Monday, July 4, 2016 at 8:16:58 AM UTC-7, רועי נגר wrote:

Tal Talmon

unread,
Oct 11, 2016, 9:36:03 AM10/11/16
to Firebase Google Group
Hello,
I am getting this error:


do you know why?

בתאריך יום רביעי, 20 ביולי 2016 בשעה 01:55:20 UTC+3, מאת Prabhaav Bhardwaj:

Jacob Wenger

unread,
Oct 11, 2016, 1:03:44 PM10/11/16
to fireba...@googlegroups.com
Hey Tal,

It looks like you aren't handling the error thrown by the sign in method. Can you share your sign in code? You probably need to add a catch() handler and inspect the error it returns.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/bc746d0c-9479-49b2-9290-dd49bd7cdc9c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Lalo Gómez Parra

unread,
Oct 12, 2016, 5:20:07 AM10/12/16
to Firebase Google Group
The same issue here.

Theres my code:

function authFacebook () {
  return new Promise((resolve, reject) => {
    LoginManager.logInWithReadPermissions(['public_profile'])
    .then(result => {
      if (result.isCancelled) {
        console.log('Inicio de sesión cancelado');
        reject('Inicio de sesión cancelado');
      } else {
        AccessToken.getCurrentAccessToken()
        .then(tokenData => {
          var credential = firebaseApp.auth.FacebookAuthProvider.credential(tokenData.accessToken);
          return firebaseApp.auth().signInWithCredential(credential);
        })
        .then(credData => {
          console.log(credData);
        })
        .catch(err => {
          console.log(err);
          reject(err);
        });
      }
    });
  });
}

CONSOLE:
TypeError: Cannot read property 'credential' of undefined(…)
YellowBox.js:69 Possible Unhandled Promise Rejection (id: 0):
Cannot read property 'credential' of undefined
TypeError: Cannot read property 'credential' of undefined
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Bassam

unread,
Oct 13, 2016, 1:28:58 PM10/13/16
to Firebase Google Group
Hey Lalo,
Is firebaseApp the app instance returned in initializeApp(config) ?
If so, this will fail.
You have to use firebase.auth.FacebookAuthProvider.credential instead.
Try that and get back to us.
Reply all
Reply to author
Forward
0 new messages