Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I grant my app permissions on pages or groups I created?

I have an app, and I can write to user's walls with it, having requested the publish_stream permission when they sign in.

I've also created a page and a group, and would like my app to be able to write to those. (Specifically, I want my back-end server to post some updates to those periodically, without a user being involved.) The ability to do this seems to be implied by the descriptions of the /feed parts of those here https://developers.facebook.com/docs/reference/api/page/ and here https://developers.facebook.com/docs/reference/api/group/ . However, I can't seem to find a way to authorize the app to write to these pages. Those docs say it can be done if you have publish_streams and manage_pages. OK, but how do I grant those to my app?

In the user case, you request those permissions when the user signs in via the OAuth flow. However, the page and the group never sign-in, so there's no way for them to grant the app permission. I looked around the settings pages for the group and the page, and couldn't find anything that will let me add the app. So how do I give the app the required permissions to post to the group and the page?

like image 361
Chris Westin Avatar asked Sep 20 '12 22:09

Chris Westin


1 Answers

Found it!

http://developers.facebook.com/docs/reference/api/application/ http://developers.facebook.com/docs/howtos/login/login-as-page/

"Application Page Access Tokens

To perform the following operations as an Application Page, and not the current user, you must use the Application's Page access token, not the user access token commonly used for modifying Graph API objects nor the Application access token. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including Application profile pages) to which the user has administrative access, along with an access_token for each Page.

Note: Applications that are configured as Native/Desktop apps will not be able to make API calls that require an application access_token."

So:

I went to http://developers.facebook.com/tools/explorer/ and, as me, created an access token with "manage_pages" permission.

I then went to https://graph.facebook.com/$myname/accounts?access_token=$accesstoken

and it gave me a list pages and apps that I had given permission to. I copied the access_token from the relevant page, and pasted that into my code, so that the server-side create event code always used that access token.

And it worked!

like image 54
Ben Curthoys Avatar answered Oct 24 '22 02:10

Ben Curthoys