How to revoke specific (or all) user permissions in Android for Facebook Login SDK -
i using latest version of facebook sdk (may 2015). how can programatically revoke/remove user's specific permission (or all) after user has logged in via facebook login sdk in android application? found following in developer documentation, not sure how programatically this. thank you.
revoking permissions easy new 4.x.x versions of facebook sdk android
for read permissions
loginmanager.getinstance().loginwithreadpermissions(fragmentoractivity, arrays.aslist("user_likes")); //multiple loginmanager.getinstance().loginwithreadpermissions(fragmentoractivity, arrays.aslist("user_likes", "user_friends"));
for publish permissions
loginmanager.getinstance().loginwithpublishpermissions(fragmentoractivity, arrays.aslist("publish_actions"));
the delete or revoking not necessary, ask permissions whenever want revoke them
for example if user has denied permission, can use above commands ask permission again.
note: must comply facebook policies, example must prompt user before asking fr permissions or ask permission when user clicks action needs permission access.
update:
if want delete permission execute graph request method delete
string graphpath="/me/permissions/user_likes"; graphrequest deletepermission=new graphrequest(accesstoken.getcurrentaccesstoken(), graphpath, null, httpmethod.delete, new graphrequest.callback() { @override public void oncompleted(graphresponse graphresponse) { if(graphresponse!=null){ facebookrequesterror error =graphresponse.geterror(); if(error!=null){ log.e(errortag, error.tostring()); }else { //permission deleted or revoked } } } }); deletepermission.executeasync(); //or deletepermission.executeandwait()
above 2 commands or similar commands can used execute graph requests if have multiple requests use graphrequestbatch (check fb documentation)
now need edit string graphpath, can replace "user_likes" permission want revoke or can remove part revoke permissions @ once.
also make sure httpmethod.delete required delete.
Comments
Post a Comment