Facebook API SDK revoke access

前端 未结 4 1347
灰色年华
灰色年华 2020-11-30 05:50

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\

相关标签:
4条回答
  • 2020-11-30 06:47

    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!

    0 讨论(0)
  • 2020-11-30 06:48

    For the FB JavaScript SDK:

    FB.api('/me/permissions', 'delete', function(response) {
        console.log(response); // true
    });
    
    0 讨论(0)
  • 2020-11-30 06:52

    With PHP SDK V 5

    $DeletePermsUser = $fb->delete('/{user-id}/permissions/',[],$access_token);
    
    0 讨论(0)
  • 2020-11-30 06:54

    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

    0 讨论(0)
提交回复
热议问题