React Native Firebase Authentication with FBLoginManager

Matthew Leak
1 min readNov 21, 2016

Over the last few days I’ve been playing with Firebase because Firebase fits perfectly with React(Native) and to understand why I recommended you read this.

When using Firebase in your application it’s preferred that all read/write requests made to your Firebase database are authenticated.

My application already uses react-native-facebook-login and I wanted to avoid writing the entire authentication section that I’d already written using FBLoginManager. I dived into the Firebase documentation to see what, if anything could be done.

By combininingsignInWithCredential() and FacebookAuthProvider I was able to take the facebook authentication token that’s returned from FBLoginManager and send this to Firebase to not only authenticate read/write requests to my Firebase database but to also take advantage of user management that’s available under the Authentication tab in the Firebase console.

FBLoginManager.loginWithPermissions(['email'], (error, data) => {
if (!error) {
const credential = firebase.auth.FacebookAuthProvider.credential(data.credentials.token);
.then(() => alert('Account accepted'))
.catch((error) => alert('Account disabled'));
} else {
console.log(error, data);

When signInWithCredential() is called, a request is made to Firebase to ensure that the Facebook user logging is enabled. In the Firebase console we have the option to disable a user should this ever be required.



Matthew Leak

UK-based Technology Consultant working in London and Manchester.