Question

Currently I call requestNewPublishPermissions to request the publish_stream permission.

Is there a way for me to see if the user has already authorized that permission so I don't need to ask it again?

I thought Session.isPublishPermission("publish_stream") might be that, but it doesn't seem to match the expected behavior.

Was it helpful?

Solution

To check if the user has already authorized a permission, you have to call the API:

\GET /me/permissions

You'll get the response in the format:

{
  "data": [
    {
      "installed": 1,
      "basic_info": 1,
      "public_profile": 1,
      "publish_stream": 1,
      "user_notes": 1,
      "user_friends": 1
    }
  ],
}

If this have the "publish_stream": 1 permission that means the user has authorized the app to publish on his behalf.

Code (if using android SDK)-

new Request(
    session,
    "/me/permissions",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top