tussh13
tussh13

Reputation: 87

firebase + facebook front end - Front end query

I am trying to do a facebook login for my firebase app. This is the first time I am using a FB login. I went through the article and small tutorials. But I am stuck at the front end

i.e the button creating part in my index.html and linking it to my firebase variable.

I saw the firefeed example and it is very differently done from the procedure on the FB developers guide. Any help will be great.

As an extension to the login I also want to access the graph data of the user logging in

This is my javascript, What will go in my HTML.

var myDataRef = new Firebase('[myFirebase]');

var authClient = new FirebaseAuthClient(myDataRef);

authClient.login("facebook", function (err, token, info) {
    if (!err) {
        console.log("Got token " + token + " for user " + info.name);
    }
});

Upvotes: 0

Views: 1895

Answers (1)

Rob DiMarco
Rob DiMarco

Reputation: 13266

Check out http://firebase.github.io/firebase-simple-login/ for an example of Firebase Simple Login in action that you can copy / fork and drop into your application.

Here's a simple example of an application which allows you to login to Facebook upon link click:

Login

  <script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
  <script type="text/javascript" src="https://cdn.firebase.com/v0/firebase-auth-client.js"></script>
  <script type="text/javascript">
    var firebaseRef = new Firebase("[myFirebase]");
    var authClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
      if (error) {
        // an error occurred while attempting login
        console.log('an error occurred:');
        console.log(error);
      } else if (user) {
        // user authenticated with Firebase
        console.log('logged in:');
        console.log(user);
      } else {
        // user is logged out
        console.log('logged out');
      }
    });
  </script>
</body>
</html>

Upvotes: 1

Related Questions