简体   繁体   中英

Facebook SDK, How do I check if a user has accepted my permissions?

I've got to a point in my app where a user can login via the Facebook SDK. The app requests read and publish permissions. Is there a way to check if they have accepted the publish permissions before carrying on? The permission is "publish_actions" . I tried doing Session.getPermissions(); but only the read permissions are listed there (basic_info, user_birthday, user_friends) .

It seems like there is no way to check if the user accepted my publish permission, is there a possible workaround to this?

The reason I need to check for this is because the permissions can be revoked by the user at any time from their profile, so I can't have them login then revoke the permissions, otherwise that would defeat the purpose of asking for it.

Would really appreciate some help, thank you. Hopefully it's possible and not a Facebook restriction (Although I can sort of see why if it was).

According to Facebook SDK v4+:

To get the list of permissions associated with the current access token, call:

AccessToken.getCurrentAccessToken().getPermissions();

To get the list of declined permissions, call:

AccessToken.getCurrentAccessToken().getDeclinedPermissions();

For your app, you can use any valid user access token, and make a call to /me/permissions, and it will return a list of permissions that the user has granted your app.

For more docs, see https://developers.facebook.com/docs/graph-api/reference/user/permissions/

I think the Best way to check for permission:

Facebook SDK 4.+ :

if (AccessToken.getCurrentAccessToken().getPermissions().contains("publish_actions")) { 
    //permission exists
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM