Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Adding FB Login to a website (Javascript)

I'm trying to add FB login to my website. The documentation here (https://developers.facebook.com/docs/facebook-login) was enough for me to set up a login button using the FB login.

My problem is, I have no idea how to access the user's information from Facebook. I don't need anything fancy, just the user's FB Id (as a way to uniquely identify the user), but I have no idea how to add it.

According to the documentation, I have to add the following (Javascript) code:

  window.fbAsyncInit = function() {
      appId            : 'app-id',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v2.12'

        FB.getLoginStatus(function(response) {
         if (response.status === 'connected') {

             var accessToken = response.authResponse.accessToken;

I added the code, and I have the "accessToken," but what I really need is a way to pull the user's FB Id, not his accessToken.