Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get user email address #120

Open
asankaub opened this issue Nov 17, 2015 · 15 comments
Open

Cannot get user email address #120

asankaub opened this issue Nov 17, 2015 · 15 comments

Comments

@asankaub
Copy link

I added following function to get email address, but its not returning the email address.
its returning only,
accessToken: ""
expiresIn: 5874
signedRequest: ""
userID: ""

Function

$scope.login = function () {
        Facebook.login(function (response) {
            if (response.status == 'connected') {
                $scope.logged = true;
                $scope.me();
            }

        },{scope: 'email'});
    };
@kim0z
Copy link

kim0z commented Jan 30, 2016

The same for me, any idea what we are missing?

@kim0z
Copy link

kim0z commented Jan 30, 2016

I found the issue, we should extract the information like this:

   $scope.me = function () {
            Facebook.api('/me?fields=email', function (response) {
                /**
                 * Using $scope.$apply since this happens outside angular framework.
                 */
                $scope.$apply(function () {
                    $scope.user = response;

                    console.log($scope.user);

                });

            });
        };

@sherizan
Copy link

sherizan commented Feb 1, 2016

$scope.me = function() {
      Facebook.api('/me', {fields: 'email,name'}, function(response) {
        $scope.user = response;
        // Examples
        $scope.welcome = response.name;
        $scope.userEmail = response.email;
      });
};

@kim0z
Copy link

kim0z commented Feb 2, 2016

Thanks, looks more arranged than my code, Cool.

@nfedosenko-old
Copy link

Is there any way to get ALL of the fields without defining them in the fields property?

@kim0z
Copy link

kim0z commented Feb 3, 2016

No, you should ask for the exact permission, and if you want more than public profile then Facebook will review your request: https://developers.facebook.com/docs/facebook-login/permissions#checking

@rochapablo
Copy link

@sherizan, I'm getting:

(#100) Tried accessing nonexisting field (public_profile) on node type (User)

Any idea?

@rochapablo
Copy link

Never mind! I've just changed to:

/me?fields=name,email,age_range,gender,locale

@melody1798
Copy link

I tried /me?fields=name,email,age_range,gender,locale.
But still couldn't get email address.
I am wondering that login window is not asking permission confirmation.
What is the problem?

@rochapablo
Copy link

I'm not sure yet, because I still working on development env. But I think that even setting these fields, you must set them at your FB dev dashboard. So that way the FB will allow you get those fields.

@LGRI
Copy link

LGRI commented Jun 7, 2016

@melody1798 Facebook will check email validity of every user, if they found the email is not in use, user email will not be return from graph api call.

@boogie1989
Copy link

boogie1989 commented Aug 9, 2016

This return email

Facebook.login(function(response) {
Facebook.api('/me?fields=name,email', function(user) {
//do something with user
});
}, { scope: 'email' });

@nitin-healthians
Copy link

I am getting email when i am login with that email id of app created account but if i am login with other email account then user email will not be return from graph api call.

@chawlaaditya8
Copy link

@nitin-healthians i am getting the same error, did you solve it?

@nitin-healthians
Copy link

@chawlaaditya8

getFBLoginStatus : function() {
Facebook.getLoginStatus(function(response) {
if (response.status == 'connected') {
userIsConnected = true;
}
else if (response.status === 'not_authorized') {
userIsConnected = false;
}
else {
userIsConnected = false;
}
});
return userIsConnected;
},
fbloginme : function() {
var deferred = $q.defer();
Facebook.login(function(response) {
Facebook.api('/me', { fields: 'email,name,gender' }, function(response) {
var opts = {
name: response.name,
email: response.email,
termscond: "1",
social_login: "Facebook",
social_response: response,
gender: response.gender
};
deferred.resolve(opts);
});
}, {scope: 'email'});
return deferred.promise;
},
fbme :function() {
var deferred = $q.defer();
Facebook.api('/me', { fields: 'email,name,gender' }, function(response) {
var opts = {
name: response.name,
email: response.email,
termscond: "1",
social_login: "Facebook",
social_response: response,
gender: response.gender
};

            deferred.resolve(opts);
        });	
        return deferred.promise;
    },
	**fblogin** : function (callback) {
		var deferred = $q.defer();
		var userIsConnected = this.getFBLoginStatus();
		if(!userIsConnected) {
			var promise = this.fbloginme();
			return promise;
		}
		else {
	    	var promise = this.fbme();
	    	return promise;
		}
	},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants