Facebook API SDK revoke access

2019-01-07 15:10发布

How can I allow a user to revoke access to my application using their API service, SDK. http://developers.facebook.com/docs/sdks/

Looking at the documentation I can't find anything about revoking the access.

4条回答
再贱就再见
2楼-- · 2019-01-07 15:48

For the FB JavaScript SDK:

FB.api('/me/permissions', 'delete', function(response) {
    console.log(response); // true
});
查看更多
手持菜刀,她持情操
3楼-- · 2019-01-07 15:49

For anyone who would find this helpful, I was losing sleep and wrecking my brain for days trying to get this to work;

FB.api('/me/permissions', 'DELETE', function(response) {
    if (response == true) {
        window.top.location = 'logout-facebook.php';
    } else {
        alert('Error revoking app');
    }
});

I finally got this to work when I observed that the "response" being returned was not a boolean but a JSON object.

The JSON object being returned was either;

{
    success: "true"
}

OR

{
    success: "false"
}

Following that, the correct code was;

FB.api('/me/permissions', 'DELETE', function(response) {
    if (response.success == true) {
        window.top.location = 'logout-facebook.php';
    } else {
        alert('Error revoking app');
    }
});   

Hope this helps someone!

查看更多
趁早两清
4楼-- · 2019-01-07 15:51

With PHP SDK V 5

$DeletePermsUser = $fb->delete('/{user-id}/permissions/',[],$access_token);
查看更多
兄弟一词,经得起流年.
5楼-- · 2019-01-07 15:57

in the graph API for the user object you can issue an HTTP DELETE request to /PROFILE_ID/permissions to revoke authorization for an app.

from the official documentation (developers.facebook.com/docs/reference/api/user/):

You can de-authorize an application or revoke a specific extended permissions on behalf of a user by issuing an HTTP DELETE request to PROFILE_ID/permissions with a user access_token for that app.

Parameter Description Type Required permission The permission you wish to revoke. If you don't specify a permission then this will de-authorize the application completely. string no You get the following result.

Description Type True if the delete succeeded and error otherwise. boolean

查看更多
登录 后发表回答