iosfacebooksocial-frameworkslrequest

Get facebook Page Access Token using SLRequest


How do I get Facebook Page Access Token using SLRequest (with a graph api call) on iOS.

I have an app that posts photos to a particular Facebook page. I've got it working through php so I know there is no issue with obtaining such permissions. But I need to do it completely in native iOS now.

In iOS, I've got post permission to said page owners feed, but that's not what I want. when I use the app token to post to a page (this is a photo album on a public facing page) it gives me 'permission denied errors'

I have this working through php using

$request = new FacebookRequest($session, 'GET', '/me/accounts?fields=name,access_token,perms');

Just need to get the same for iOS using SLRequest as I'm using iOS Social framework

Thanks for the help


Solution

  • You should not make call to the Graph API using an App Access Token from a device. That is because the App Access Token should be considered like a password; storing it on a device is insecure because the token can be extracted using special software.

    You can read more about this here: https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens

    ...Again, for security, app access token should never be hard-coded into client-side code...

    You can handle your situation in two ways:

    1. Just make the call using the User Access Token. If you have the correct permissions from the user, you can post as that page to the photo album.
    2. Send the data to your own servers and make a call, using App Access Token, from there to the Graph API.

    I would suggest you use method 1. Its also for your rate limiting better to use User tokens instead of App tokens.