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

1

15

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?

Separate answered 20/9, 2012 at 22:36 Comment(0)
U
2

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!

Ube answered 10/1, 2013 at 15:18 Comment(4)
No, that doesn't work. The page token times out after 2 hours. developers.facebook.com/docs/howtos/login/login-as-pageUbe
Yep, I had the same results as Ben Curthoys - after a couple of hours it stopped working.Othilia
How did you end up solving this @BenCurthoys ?Decurion
It was half and half between: "I gave up and found another solution to the problem" and "Facebook made it completely explicitly impossible to do what I wanted so there was no point in trying". What I wanted this for was to create an Event for a venue page through the API and that stopped being an option: developers.facebook.com/docs/graph-api/reference/v2.0/…Ube

© 2022 - 2024 — McMap. All rights reserved.