How to revoke all Facebook permissions using the Android SDK?

I have a problem with revoking Facebook permissions using the Android SDK.

There is a case in my application when I want to revoke all permissions. According to the documentation on Facebook, you can use AsyncFacebookRunner for this, and "if you do not specify permission, this completely cancels the application."

I am currently doing it like this:

String method = "DELETE";
Bundle params = new Bundle();
params.putString("permission", "");

mAsyncRunner.request("/me/permissions", params, method, new RequestListener()
                     { ... }, null);

using the request signature as follows:

void request(String graphPath, Bundle parameters, final String httpMethod,
             RequestListener listener, final Object state)

The onComplete () callback function seems to have returned to OK, but does not seem to have allowed the access token. I deduced this because the next time I call facebook.authorize (), it works without clicking the user on the Facebook login page.

, , ? / ? !

+3
4

: Facebook , . , onCreate(), / .

: , Facebook. - -, - , , ! .

0

, API SDK/Graph. , https://developers.facebook.com/docs/graph-api/reference/user/permissions/

new Request(
   session,
    "/me/permissions/{permission-to-revoke}",
    null,
    HttpMethod.DELETE,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();

/{permission-to-revoke}

+3

( ) Facebook SDK ( 4.1.1)

void deleteFacebookApplication(){
    new GraphRequest(AccessToken.getCurrentAccessToken(), "/me/permissions", null, HttpMethod.DELETE, new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            boolean isSuccess = false;
            try {
                isSuccess = response.getJSONObject().getBoolean("success");
            } catch (JSONException e) {
                e.printStackTrace();
            }
            if (isSuccess && response.getError()==null){
                // Application deleted from Facebook account
            }

        }
    }).executeAsync();
}
+1

, , . , .

This is also the code suggested in the official documentation on facebook: https://developers.facebook.com/docs/mobile/android/build/ - Step 7

0
source

All Articles