I'm getting the following error when I try to access the Graph API with my access token:
{
"error": {
"message": "Expected 1 '.' in the input between the postcard and the payload",
"type": "OAuthException",
"code": 1
}
}
I'm grabbing the access token after successfully authenticating an app I'm working on. I have accepted the permissions and I'm hitting the app's landing page. The access token doesn't look like others I've seen online. It doesn't have the '|' character in it. It does have a period and some underscores along with the typical alphanumeric combination.
I figured out the problem. The other developer I was working with used part of the raw signed_request object (not parsed) to form the access token. After taken a gander at the documentation, I quickly realized that you need to parse the signed_request object first before obtaining the oauth_token value. After that was fixed, I was able to easily make an API call.
Check to ensure you are verifying the "code" parameter returned by Facebook before signing the request, not the "access token". Signing a request with a bad access token produced this error message for me.
Related
I was Unable to get the search result in Facebook Graph Api Explorer For Topic search API. I am getting the following error. I also have the access token included.
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15,
"fbtrace_id": "CJiZqVSATXu"
}
}
Well, the error message actually contains the problem. You're not using an App Access Token, but seemingly an User Access Token (from the Access Token structure in your screenshot).
You must select an app of yours in the upper right Applications dropdown, and then select Get App Token in the dropdown below.
Still, that will probably not help much in this case. Are you aware that only whitelisted apps can use the Topic Search API?
See
https://developers.facebook.com/docs/graph-api/using-graph-api#search
https://developers.facebook.com/docs/mediasolutions/topic_search/v2.5
I'm trying to get a Facebook access token that never expires but I cannot manage to do it. Here is my steps:
1) Use Facebook graph explorer to generate a short live access token with the desired permissions (this token is valid for 1h or so)
2) Get a long live token (2 months expiry time) by manual GET request to
https://graph.facebook.com/oauth/access_token?
grant_type=fb_exchange_token&
client_id=[app-client-id]&client_secret=[app-secret-id]& fb_exchange_token=[short-live-access-token]
3) An this tohttps://graph.facebook.com/[user-id]?fields=access_token&access_token=[long-live-access-token]
but that last steps show an error:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (access_token) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "DpmM6CyzoAt"
}
}
I have found that last step somewhere on the net so I presume FB must have change something, I have read their api doc but I cannot figure out by what resource they chance the step 3.
Could someone explain me how to get a user access token that never expires ?
thank you
User Tokens are never valid forever, an extended one is only valid for 60 days as you have found out already. I assume you want to get an Extended Page Token, that´s how you can get one:
https://graph.facebook.com/[page-id]?fields=access_token&access_token=[long-live-user-token]
Basically, you just need to use a Page ID, it does not work with a User ID.
I went to https://developers.facebook.com/tools/explorer?method=GET, set up there ID of my Facebook page, set up there the correct permission for posting statuses on my FB timeline and generated access token.
Then I wanted to extend this short-live token on the long-term (60 days long valid token). So I did following - I put this URL to the browser:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID_OF_MY_FB_APP&client_secret=SECRET_ID_OF_MY_APP&grant_type=fb_exchange_token&fb_exchange_token=GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP
and in the browser I saw this error message:
{
"error": {
"message": "The access token does not belong to application APP_ID_OF_MY_FB_APP",
"type": "OAuthException",
"code": 1
}
}
Which is weird, because the APP_ID of my Facebook app is correct, I've tried to post on the wall of the Facebook page and it was working.
But when I try to get extended access token, I am getting the error above.
What's wrong with the access?
Thank you
This almost certainly means what the error says, which is that GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP is not actually from the app ID that you're using in the APP_ID_OF_MY_FB_APP parameter
Check the access token you're trying to extend in Facebook's Debug Tooland ensure it was actually generated for your app
Your AppID param is not the same to the AppID in developers.facebook.com
I am trying to register a Facebook open graph achievement for an app. I obtain the app access token and post the following request using open graph API explorer:
https://graph.facebook.com/752901688356092/achievements&achievement=https://googledrive.com/host/0B1R_JKMKJc2KbkNqZTdleEZvOUE/brags/fb_achive_100_words.html&display_order=100&access_token=752901688356092|pPwn52AvX-Pkj2n8Tavopew5Rav
(note that app ID an access token above are not the real ones). However, I get the following response:
{
"error": {
"message": "Unknown path components: /achievements&achievement=https://googledrive.com/host/0B1R_JKMKJc2KbkNqZTdleEZvOUE/brags/fb_achive_100_words.html&display_order=100&access_token=752901688356092|pPwn52AvX-Pkj2n8Tavopew5Rav",
"type": "OAuthException",
"code": 2500
}
}
I have registered the app as a games type app and I have verified the achievement URL using open graph debugger (it shows the achievement and reports everything is fine). I also tried the above without the app-ID included in the access token. What could I be missing?
You have an error in the way your URL is composed. The first GET parameter is supposed to be separated from the base URL by a ?, not a &. Try the following :
https://graph.facebook.com/752901688356092/achievements?achievement=https://googledrive.com/host/0B1R_JKMKJc2KbkNqZTdleEZvOUE/brags/fb_achive_100_words.html&display_order=100&access_token=752901688356092%7CpPwn52AvX-Pkj2n8Tavopew5Rav
This throws another error, but that might also be caused by a missing AUTH token. Why don't you have a look at how they suggest you do it? You probably need to check the setup of the achievement.
I did quite a bit of homework before posting here but still could not find a solution for the following problem.
PROBLEM: when trying to access my facebook app's insights or subscriptions, it returns
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
I do everything according to the official documentation:
get app access_token by calling this api. It does return a token.
https:// graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
get insights/subscriptions by calling: https:// graph.facebook.com/APP_ID/subscriptions?access_token=TOKEN_FROM_STEP_1
but the last call returns the error message above.
Any ideas why?
After many trials and errors I found the solution.
Change facebook app type to 'Web' instead of 'Native'
Apparently facebook doesn't return subscriptions/insights for native apps