Facebook authentication with Firebase
Posted By : Ankit Sharma | 30-Sep-2015
To integrate facebook authentication in your firebase application, you need to first creat a new facebook application.
Go to https://developers.facebook.com/apps and login with your credentials and click on Add a new App.
Next you need to create a new app id
Provide display name and choose your app category and click create.
Next, lookup for App ID and App secret.
Now click on setting on left panel and then advance on top panel and then put this
https://auth.firebase.com/v2/myApp/auth/facebook/callback in Valid OAuth redirect URIs textbox, replace myApp with your app name.
click save changes.
So, we have successfully created a facebook application.
Now, click on Manage App button of you firebase application.
Now select login and auth tab from left panel and then select Facebook as the authentication provider. Fill your facebook App ID and App Seceret here.
You are all set with the configuration, now it’s time to code.
If your user don’t have an existing session than you can prompt your user to login and then invoke the facebook login popup with the following snippet
var ref = new Firebase("https://firebaseloginApp.firebaseio.com");
ref.authWithOAuthPopup("facebook", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully", authData);
}
});
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ankit Sharma
Ankit is a Technical Project Manager with expertise in Java, Spring Framework, Artificial Intelligence, Machine Learning, and Team Management. In his free time, he likes to read books and listen to music.