Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function fb_login(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
//console.log(response); // dump complete info
access_token = response.authResponse.accessToken; //get access token
user_id = response.authResponse.userID; //get FB UID
FB.api('/me?fields=id,name,friendlists', function(response) {
user_email =; //get user email
// you can store this data into your database
} else {
//user hit cancel button
console.log('User cancelled login or did not fully authorize.');
}, {
scope: 'publish_stream,email,read_friendlists'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment