I am using the latest version of Facebook SDK (May 2015). How can I programatically revoke/remove a user's specific permission (or all) after the user has logged in via Facebook Login SDK in an Android Application? I found the following in the developer documentation, but I am not sure how to programatically do this. Thank you.
I found the solution on how to Revoke a User's Permission in the latest version of Facebook Android SDK (Graph API 2.0+ and above). This is per May 2015. The developer needs to use GraphRequest.newGraphPathRequest() and set the GraphPath and set the HttpMethod to DELETE.
public void graphRevokeUserStatusPermission(){
AccessToken accessToken = AccessToken.getCurrentAccessToken();
if(accessToken == null)
return;
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/me/permissions/user_status",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// response
}
}
);
request.setHttpMethod(HttpMethod.DELETE);
request.executeAsync();
}
and if you want to revoke user access just change graph path to
String userId = accessToken.getUserId();
//url to revoke login DELETE {user_id}/permissions
userId + "permissions"
and don't forget to clear info in onCompleted method calling LoginManager.getInstance().logOut(), this logout method doesn't revoke access, it just clear token and profile info, so developer needs to request url to revoke access
More info: