You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to fetch user details and oauth authenticate user through facebook api's and java and able to authenticate and redirect to my home page but the facebook api's are not returning details like email , birthday, friend list but only returns username and id and the rest details as null. I have registered my App on facebook and still why i am not able to fetch other details like birthday , email , friendlist,profile picture etc.
Below is the code :
This is Main Menu Class :
public class MainMenu extends HttpServlet {
private static final long serialVersionUID = 1L;
private String code="";
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String clientId = "XXXXXXXXXXXXXXXXX";
String clientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
//public static final String REDIRECT_URI = "http://localhost:8080/Facebook_Login/fbhome";
Client client = new Client(clientId, clientSecret);
FacebookFactory facebookFactory = new FacebookFactory(client);
String redirectURL = facebookFactory.getRedirectURL("http://localhost:8080/Facebook_Login/fbhome", Display.POPUP, Permission.EMAIL, Permission.OFFLINE_ACCESS);
String code = req.getParameter("code");
OAuthAccessToken accessToken1;
try {
accessToken1 = facebookFactory.getOAuthAccessToken(code, "http://localhost:8080/Facebook_Login/fbhome");
Facebook facebook = facebookFactory.getInstance(accessToken1);
User fbUser = facebook.getCurrentUser();
System.out.println("fbUser"+"====="+fbUser.getName());
ServletOutputStream out = res.getOutputStream();
res.reset();
out.println("<h1>Facebook Login using Java</h1>");
out.println("<h2>Application Main Menu</h2>");
out.println("<div>Welcome "+fbUser.getName());
out.println("<div>Your Religion: "+fbUser.getReligion());
out.println("<div>Your Birthday: "+fbUser.getBirthday());
out.println("<div>Your Gender: "+fbUser.getGender());
out.println("<div>Your Locale: "+fbUser.getLocale());
out.println("<div>Your ID: "+fbUser.getWork());
out.println("<div>Logout: "+"<a href='https://www.facebook.com/logout.php?next="+"http://localhost:8080/Facebook_Login/fbhome&access_token="+accessToken1+"'>Logout"+"</>");
//out.println("<div>Your Education: "+fbUser.home(facebook));
Map<String, String> fbProfile = new HashMap<String, String>();
JSONObject json = new JSONObject(fbUser);
try {
fbProfile.put("id", json.getString("id"));
System.out.println("fbProfile"+fbProfile);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FacebookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*out.println("<div>You are "+fbProfileData.get("gender"));
out.flush();*/
}
}
I am trying to fetch user details and oauth authenticate user through facebook api's and java and able to authenticate and redirect to my home page but the facebook api's are not returning details like email , birthday, friend list but only returns username and id and the rest details as null. I have registered my App on facebook and still why i am not able to fetch other details like birthday , email , friendlist,profile picture etc.
Below is the code :
This is Main Menu Class :
and I am using face4j-1.5.11.jar
Below is the html
The text was updated successfully, but these errors were encountered: