At the moment, I try to query the Facebook Open Graph Api.
My problem is the following:
Calling: https://graph.facebook.com/endpoint?key=value&access_token=app_id|app_secret results in
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
Also when I first receive an access token and use it, the same error appears. In the case, that I use an access token which I receive from the Graph API Explorer, everything works fine. https://developers.facebook.com/tools/explorer)
Comparing the access token I receive from Facebook and the access Token of the Graph API Explorer I see a difference in the length because the second token is much longer. (I think its a session token if I am not wrong)
How can I get such a token in order to do the mentioned API call?
Your appId and secret are used to generate your access_token, they aren't actually the token so there's something wrong with your process. Some sample code might help determine where you're going wrong. Though please don't actually post your appid and secret here.
https://developers.facebook.com/docs/facebook-login/overview/#loginflows
You haven't stated what language you are using, but there are a number of SDKs out there already that will simplify this process.
At the bottom of the above page, there are a number of links that will walk you through the login process for different platforms so I suggest you take a look at these
Related
I am trying to connect a bot to Facebook messenger, using Facebook developer tools.
https://developers.facebook.com/
I've created the Facebook app, and it's sent me the webhook to my server. However, when trying to call the Graph API when sending a message back to the user, I receive the following error:
FacebookMessaging:400 : {
"error": {
"message": "(#2) Service temporarily unavailable",
"type": "OAuthException",
"is_transient": true,
"code": 2,
"fbtrace_id": "AIWsRyUmPFnySGwb1Rgl4P6"
}
}
POST API,
https://graph.facebook.com/v10.0/page-id/messages?access_token=token
JSON
{recipient:{id:"id"}, message:{ text:"message"}}
I suspect it could be because my app is unreleased, but I'm trying to test it beforehand. Is there any other explanation for this, or how are you suppose to test an app before releasing it?
The same code is working for an older Facebook app that is released.
The issue was that the API call was missing the access token. Stupid mistake, but unusual error for missing the access token.
I already try and reproduce this problem. May be you use wrong access_token in this case. When you want to send the message by page, use should use page access token instead of user access token
Check out the diff here: https://developers.facebook.com/docs/facebook-login/access-tokens/
And flow here for get page access token: https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens
It is clearly return you the response with type as OAuthException. If you find this error type in facebook garph api error handling documentation. You can see the first line of error codes is OAuthException. Also it is written there the resolution of this type of error in what to do column is, If no subcode is present, the login status or access token has expired, been revoked, or is otherwise invalid. Get a new access token.
If a subcode is present, see the subcode.
Well it is nice to see you get the answer on your own.
I have a really weird situation here, and I've looked everywhere through Facebook's documentation with no answers.
I'm trying to get get recent posts from multiple Facebook pages. But one of them keeps crashing. It won't work when I'm using an app token. It works if I'm using access tokens, but those expire, so it'd be better to not use that.
https://graph.facebook.com/norgeshushonefoss/posts?access_token=myAppToken
gives this result:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
While this url gives me the recent posts: https://graph.facebook.com/norgeshus/posts?access_token=myAppToken
I can't see any difference in those two. Are there any page settings that may cause an app token not to authorize for some reason?
If the page has any access restrictions in place (age, location, alcohol-related content), then you can not access any of its info using your app access token.
It needs a user access token for a user that qualifies to see the page (or a page access token).
We are facing issues with Graph API. The Facebook Graph API "/{page-id}/feed" is not working for all pages with a valid App Access Token. Previously it used to work. We noticed it today the API is throwing error
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
Not working pages:
https://graph.facebook.com/22934684677/feed?access_token=
https://graph.facebook.com/42798291365/feed?access_token=
Note: And its working if we pass a User Access token instead of App Token.
Facebook developer Docs says "An access token is required to view publicly shared posts." So App Access Token should work!
Does Facebook change something inside the API?. Can any one help to solve the issue
You should use a Page Token for Page data. Pages not working with an App Token are most likely restricted by age or location. Since the App Token does not include any user session, you canĀ“t be sure if the user should have access to it.
If it does not work with an App Token AND the Page is definitely not restricted, file a bug.
This is happening because some of the posts returned might have extra restrictions on them which need a user token to verify this. Use a page token or a user token as a workaround for this. Having said that, the request shouldn't fail with an unknown error and we're working on a fix for the same on the bug report here:
https://developers.facebook.com/bugs/783169051760311/
I'm trying to post the following the facebook Graph API explorer.
cody.short.94/notifications? access_token= {User Access Token} &template= this is a test &href= www.test.com
I want to be able to send the user a notification, but all attempts have failed. I'm currently getting this error:
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
}
I'm not sure what is causing it, and I'm in need of some guidance. Any help would be appreciated. note: my app is currently marked for web so that it not the problem
See, the error is quite self-explanatory :
This method must be called with an app access_token
The Notifications API use the APP Access Token, not the user access token!
The App Access Token is: APP_ID|APP_SECRET or get directly from here for testing. (Make sure of the security of this token, this is very crucial and just like a password to your app)
Now test the query with Graph API Explorer , and remove the user token from the Access token field and replace it with the App Access Token
It will look something like this-
Make sure you paste the app access token APP_ID|APP_SECRET on the top field that says Access Token
I'm trying to obtain messages and attachments from Facebook, I'm using:
https://api.facebook.com/method/message.getThreadsInFolder?access_token=AT&folder_id=0
To get the list of threads and:
https://graph.facebook.com/fql?access_token=AT&q=QUERY
For my queries.
But, every time, I copy the access token generated by the Graph API Explorer as I don't seem to be able to get it programmatically:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=ID&client_secret=SECRET
Gives me an access token, but it doesn't work. If I try to use it with the URLs above I get:
"error_msg":"A session key is required for calling this method"
And for the second one:
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190
The Facebook documentation it's really unclear.
I do not want to use a login flow, is there a way to login programmatically with the stored credentials as the mobile application does?
You need a login flow which you are not using (https://developers.facebook.com/docs/facebook-login/). It is not possible to get a user access token programmatically. This defeats the point of manual user interaction. The user must explicitly grant access to your application.