RED_
RED_

Reputation: 3007

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).

Upvotes: 2

Views: 3801

Answers (3)

Mohamed Salah
Mohamed Salah

Reputation: 1205

I think the Best way to check for permission:

Facebook SDK 4.+ :

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

Upvotes: 2

ulusoyca
ulusoyca

Reputation: 881

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();

Upvotes: 5

Ming Li
Ming Li

Reputation: 15662

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/

Upvotes: 3

Related Questions