Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting null for user email - restfb

I've recently started working on manual login flow of facebook. And followed this blog to get the access token and using restfb to access user information.
Below is the code snippet as mentioned - Fetching Single Objects:

FacebookClient facebookClient = new DefaultFacebookClient(ACCESS_TOKEN, APP_SECRET);
User user = facebookClient.fetchObject("me", User.class);

I'm successfully able to get the user's name, first name and last name but it returns null for email (user.getEmail();).

My facebook app has default permissions as: permissions

Anyone help me how can I access the user email?

UPDATE

I've been trying the graph-api explorer to see what I'm getting for email graph-api explorer and it says Field is empty or disallowed by the access token. What do I'm supposed to do to fix this?

like image 260
Mohammad Faisal Avatar asked Apr 19 '26 11:04

Mohammad Faisal


1 Answers

Try this

User me = client.fetchObject(yourId, User.class,Parameter.with("fields", "email"));
like image 106
nirman11 Avatar answered Apr 22 '26 01:04

nirman11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!