How to revoke a permanent Facebook 'page' token with API v2.2? - facebook

I've created an application that only stores Facebook Page tokens. My application publishes content to pages.
I'm migrating from v1.0 to v2.2. I used to revoke Page tokens by calling a DELETE on /me/permissions. But now the API returns:
Unsupported delete request. Please read the Graph API documentation
at https://developers.facebook.com/docs/graph-api
How can I delete a page token with the new v2.2 Graph API?

I'd file a bug if there is a feature in 1.0 that hasn't been listed as removed in the change log.
On the other hand, I've never heard of such a call. If it existed, it's either a really old call or a bug in the API.
If you revoke a fan page token, how would you reissue it?
The only token you can revoke to my knowledge is the user token.
In addition, I tested a few 1.0 applications and no such call exists.

Page tokens are not revocable. Only user tokens are revocable.

This is not done via the API, but as the page admin, you can revoke access previously granted to an app. You do so via your profile settings on a section called business tools. This section allows you to view apps with access and revoke their access, immediately invalidating page access tokens granted by you to that app.
https://www.facebook.com/settings?tab=business_tools

Related

How to access Facebook page posts with app credentials?

I've been working on getting an old server-to-server Facebook app working which was previously used to load a feed of page posts for pages we own, but even after completing the review for manage_pages access I still get the error "This endpoint requires the 'manage_pages' permission or the 'Page Public Content Access' feature" when I try to access the feed via
https://graph.facebook.com/[page_id]/posts?access_token=[app access token]
or
https://graph.facebook.com/[page_id]/feed?access_token=[app access token]
I've tried generating the app access token with the Graph API explorer and also tried using [app ID]|[app secret] as the access token, but get the same result either way. Is there something I need to do to grant the app manage_pages access for specific pages now facebook's reviewed it, or is there something else I'm missing? The user that created the app can access the data if using a page access token, but since they removed the ability to create permanent page access tokens that's not really a viable option
edit: Looking into the documentation, it seems I should be able to request a page access token using the app authentication now that it's been approved for manage_pages permissions. However, trying to access one with https://graph.facebook.com/v5.0/[page ID]?fields=access_token&access_token=[app access token] also generates the manage_pages or Public Content permissions error, which seems like it would suggest the app doesn't actually have manage pages permissions?

Using Instagram Graph Api with permanent page access token only works for some accounts

I try to fetch some images from an instagram business account through the instagram graph api by means of a permanent page access token (facebook: permanent Page Access Token?). These specific tokens seem to be the only possibility to get permanent access to the graph api for a server-side app.
On the other side I found a hint in the fb documentation that only user accesss tokens can be used to access instagram business accounts.
"Page access tokens are not supported."
https://developers.facebook.com/docs/instagram-api/overview/?locale=en_US
Funny enough I was using page tokens so far without any problems. After resetting the database of my project and generating new tokens I observered that some accounts weren't able to fetch the data while others had no problems.
"Unsupported get request. Object with ID 'XXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation."
I had 2 instagram accounts: 1 was working with page access tokens the other didn't. So, I checked it in the fb graph explorer. Using the user access token I have no problem with both accounts. Using the page access token respectivly for both accounts one is working fine for the query while the other isn't. A third account that I created has the same problem.
Things I tried to resolve the issue:
deleting all permanent page access tokens from my database and generate them again
generate the permanent page access tokens manually by means of the fb graph explorer tool
turn my instagram account back into personal and then again into a business account through the app
turn my instagram account back into personal and then again into a business account through the facebook page
create a new instagram account and a new facebook page to connect (repeating 3. and 4.)
My questions now:
Can I use permanent page access tokens for the instagram graph api?
If not, how do I get permanent server side access to the instagram graph api?
I am now searching the internet and stackoverflow for days and getting crazy because I seem to be the only person experiencing this problem. So, help will be highly appreciated by my fellow developers. Tia.
Since yesterday everything works fine again also when using the permanent page access token. Seems like fb resolved an internal bug. However, the question remains, if page access token can be used in general or if it is just a bug itself.

How to generate Facebook Marketing API access token to use it in Windows application

I am using Facebook as advertising platform to promote my application on Apple and Google stores. I would like to make windows service which will download daily report(s) about advertising status of my marketing campaign running one Facebook, preferably using 60 day token, or some permanent solution so that token is retrieved when required. I think that i understand everything to do this except how to generate access token to use it with Facebook Graph API. Which token for which Facebook account do I need and how to obtain it?
You'll need a Facebook app and to grant that app the ads_read permission in order to retrieve reports about your advertising efforts via the API (source).
You'll want a long-lived token so that you don't have to re-authenticate very often. The access token documentation details the steps to exchange a short-lived token for a long-lived one.
You may also want to consider managing the app, ad account, and access tokens (via a business system user) with the FB Business Manager.
Create a facebook app.
Go to the Graph API Explorer in Facebook's Tools & Support section.
Pick your app from the drop down.
Hit Get Token > Get User Access Token.
In Select Permissions choose required permissions or select them from extended permissions.
Use the user access token that will be presented to you in the access token form input field.

Automatic post to my facebook page from Node.js server

I have a Node.js server running a social network site and I also have a facebook page for that site. For certain actions performed by users on my site, I want to post details on the facebook page of my app.
I referred to Thuzi facebook node sdk here on how to post to facebook wall. However, it requires app id, app secret and a temporary access token. App id and app secret are constant so I can put them somewhere in my config file and use from there. But how do I get the access token without any interaction from front-end ? All posts will be published by our app only and that too on our own page. I just want this to be triggered by the end user's actions. Any help ?
I am using Sails.js framework btw.
You would need to use an Extended Page Token for that, you only need to create it once and it will stay valid forever. And you will post "as Page" with a Page Token. How to get an Extended Page Token:
Create an App
Use the Graph API Explorer to generate a User Access Token (by authorizing the App with the manage_pages and publish_actions permission)
Extend the User Access Token (valid for 60 days)
Request an Extended Page Token by calling /me/accounts
Store that Extended Page Token on your server and use it for posting on the Page wall.
Here are some additional resources, explaining everything in detail:
https://developers.facebook.com/docs/facebook-login/access-tokens/
https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed
http://www.devils-heaven.com/facebook-access-tokens/
http://www.devils-heaven.com/extended-page-access-tokens-curl/
I am also digging more in to this nowdays As I am working on a node module for this.
Till now I got to know that we can create a temporary access_token and we can than extend that token upto max 60 days.
For this after getting temporary token you need to make a call to this url to get a access token with 60 days validity.
https://graph.facebook.com/oauth/access_token?client_id=&client_secret=&grant_type=fb_exchange_token&fb_exchange_token=

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?
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!