android parse sdk facebook login cannot get email -
im integrated parse , facebook sdk project , work , id , user name of facebook user issue cannot thing else email or gender or other information add permission them.
this permission :
private static final list<string> permissions = arrays.aslist("public_profile","email","user_friends","user_birthday","user_location","user_relationships");
button click code :
button mbtnfb=(button)findviewbyid(r.id.mbtnfb); mbtnfb.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { parsefacebookutils.loginwithreadpermissionsinbackground(mainactivity.this,permissions , new logincallback() { @override public void done(parseuser user, parseexception err) { if (user == null) { log.d("myapp", "the user cancelled facebook login."); } else if (user.isnew()) { log.d("myapp", "user signed , logged in through facebook!"); getuserdetailsfromfb(); } else { log.d("myapp", "user logged in through facebook!"); getuserdetailsfromparse(); } } }); } });
get user details facebook:
public string name,email; parseuser parseuser=new parseuser(); private void getuserdetailsfromfb() { graphrequest request = graphrequest.newmerequest( accesstoken.getcurrentaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted( jsonobject object, graphresponse response) { try { string id=object.getstring("id"); string name=object.getstring("name"); string email=object.getstring("email"); string gender=object.getstring("gender"); string birthday=object.getstring("birthday"); } catch (jsonexception e) { e.printstacktrace(); } } }); bundle parameters = new bundle(); parameters.putstring("fields", "id,name,link,email"); request.setparameters(parameters); request.executeasync(); }
i id , name , other info give me exception suggestion ?
i had same issue, here's how solved it:
- go https://developers.facebook.com/
- click "tools & support" (at top menu)
- click "graph api explorer" (at left side menu called "tools")
- where says "application: graph api explorer" (at top right) change application working with.
- where says "get token" click "get user access token"
- tick "user_about_me"
- click on "extended permissions"
- tick "email"
- click "get access token"
- facebook may prompt confirm.
this should give application permission retrieve email address of facebook user.
hope helps.
regards, nathanial
Comments
Post a Comment