Facebook Token returns Empty Android -
im having issue when try sign face book following in log cat
07-11 10:15:07.757: w/com.facebook.session(8910): should not pass read permission (user_likes) request publish or manage authorization 07-11 10:15:07.772: w/com.facebook.session(8910): should not pass read permission (email) request publish or manage authorization 07-11 10:15:07.777: w/com.facebook.session(8910): should not pass read permission (user_birthday) request publish or manage authorization 07-11 10:15:07.787: w/com.facebook.session(8910): should not pass read permission (user_location) request publish or manage authorization 07-11 10:15:08.797: v/log_tag(8910): token= 07-11 10:15:08.797: v/log_tag(8910): token=false
i followed proper documentation of facebook used code generate sha key , placed on console disable sand box enable face book login disable deep linking still no luck code used face book following
facebookbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub session.openactivesession(signin_rewards.this, true, new session.statuscallback() { // callback when session changes state @override public void call(session session, sessionstate state, exception exception) { log.v("log_tag", "token=" + session.getaccesstoken()); log.v("log_tag", "token=" + session.isopened()); session currentsession = session.getactivesession(); if (currentsession == null || currentsession.getstate().isclosed()) { session = new session.builder(signin_rewards.this).build(); session.setactivesession(session); currentsession = session; } else if(!currentsession.isopened()) { //ask username , password openrequest op = new session.openrequest(signin_rewards.this); op.setloginbehavior(sessionloginbehavior.sso_with_fallback); op.setcallback(null); list<string> permissions = new arraylist<string>(); permissions.add("publish_stream"); permissions.add("user_likes"); permissions.add("email"); permissions.add("user_birthday"); permissions.add("user_location"); op.setpermissions(permissions); session = new session.builder(signin_rewards.this).build(); session.setactivesession(session); session.openforpublish(op); } else if (session.isopened()) { // make request /me api request.executemerequestasync(session, new request.graphusercallback() { // callback after graph api response user // object @override public void oncompleted(graphuser user, response response) { if (user != null) { /* textview welcome = (textview) findviewbyid(r.id.welcome); welcome.settext("hello " + user.getname() + "!");*/ finish(); log.d("user name",""+user.getname()+" "+user.getfirstname()+" "+user.getlastname()+" "+user.getproperty("email")+user.getbirthday()+user.getlocation().getproperty("name")); } } }); } } }); } }) ;
please correct me wrong
i've seen problem happen because of wrong hash key generation. rather doing keytool stuff try pasting code in 1 of oncreate generate right key , paste app section on facebook.
packageinfo info; try { info = getpackagemanager().getpackageinfo("com.you.name", packagemanager.get_signatures); (signature signature : info.signatures) { messagedigest md; md = messagedigest.getinstance("sha"); md.update(signature.tobytearray()); string = new string(base64.encode(md.digest(), 0)); //string = new string(base64.encodebytes(md.digest())); log.e("hash key", something); } } catch (namenotfoundexception e1) { log.e("name not found", e1.tostring()); } catch (nosuchalgorithmexception e) { log.e("no such algorithm", e.tostring()); } catch (exception e) { log.e("exception", e.tostring()); }
this generate key in logcat. check this more ways generate hash key correctly
Comments
Post a Comment