Facebook API OAuthException: “An unexpected error has occurred. Please retry your request later” when trying to retrieve a Page-specific access token
Solution 1
Just suddenly started working this morning—no idea why.
Solution 2
I think I can shed a little more light on this.
I get this return often when making a request for the Page specific access tokens; failures on this call seem to be proportional to the number of Page's that are administered by the account for which the access token is for, so if you admin 100 pages, you will fail more often than if you have 1 pages, if you have a 5000 pages failures will happen more often than they don't.
This indicates that the failure is related to the response size, as the JSON returned can be very lengthy for large sets of Page's.
The fix for this is simple. Instead of requesting all of the Page's using
http://graph.facebook.com/me/accounts?access_token={admin access token}
use
http://graph.facebook.com/{page id}?fields=access_token&access_token={admin access token}
This will return the access token for just that page. Because the response is small you should experience Facebook server-side errors much less frequently. Since I switched I don't think I've ever experienced a failure and I make the call very often.
Solution 3
Try this... https://graph.facebook.com/me/accounts?access_token=TOKEN_FROM_ABOVE&expires_in=6483
Comments
-
Mark Bell almost 2 years
I want my app to be able to post status updates to a specific Page. I've got an application set up and retrieved its app ID, and I'm following the the “Page Login” section at the bottom of the Facebook authentication documentation here.
The first stage (user granting the app the
manage_page
permission) seems to work perfectly. I get redirected to a URL like this:http://myapp.com/#access_token=ACCESS_TOKEN&expires_in=6483
The docs then say you should access the following:
https://graph.facebook.com/me/accounts?access_token=TOKEN_FROM_ABOVE
replacing
TOKEN_FROM_ABOVE
with the one returned by the previous request, and this should return “a list of all the Pages the user administers including Page specific access token for each Page”.However, it doesn't. All I get is the following JSON response:
{ "error": { "message": "An unexpected error has occurred. Please retry your request later.", "type": "OAuthException" } }
What am I doing wrong? Could I have set something up incorrectly when creating the application? The error message is less than helpful, so any assistance would be much appreciated.
-
Mark Bell over 12 yearsI get the same error. Also, why would you pass in the
expires_in
property? Surely that's a read-only parameter that would be set by Facebook when issuing the token? -
Mark Bell over 12 yearsThanks—I don't think this was the issue, as my test account was only administering one page, but +1 for pointing out a way to retrieve just the token for a specific page.
-
Mark Bell almost 12 yearsWell, random downvoter, that's what happened. What did you want me to write?
-
mmrobins almost 12 yearsHow would you get back the page ids to insert into the page specific call? The only endpoint I know to do that is the accounts endpoint, and I'm getting the same error as the original poster when I hit the accounts endpoint.
-
Ben E G over 10 yearsAhah nice response. Also I have 15 apps monitoring 15 FB Pages legitimately as an admin. We grab data once an hour, then process posts and comments based on hashtags. It has been running for about 2 months. Once every few days one of the apps will get this error. Next time it runs (via a scheduled task) the error is gone. Some serious FB api gremlins
-
Mark Bell over 10 yearsYep, the fact that my (essentially useless) answer has a number of upvotes suggests that several others have encountered these odd, intermittent issues with the Facebook API...