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
Related
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/
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
I have read this:
trying to get app access token
And it doesn't work...
I'm getting the following error:
"error": {
"message": "An active access token must be used to query
information about the current user.",
"type": "OAuthException",
"code": 2500
}
I need the app access token in order to create open graph objects that are owned by the application.
I know how to create objects owned by the users, but I just cant find the correct way of creating the App access token.
AppId -> doesn't work...
AppId|AppSecret -> doesn't work....
App ClientToken -> doesn't work....
Anyone know this?
You can get it directly from the Access Token Tool.
Please note: For security, app access token should never be hard-coded into client-side code, doing so would give everyone who loaded your webpage or decompiled your app full access to your app secret, and therefore the ability to modify your app. This implies that most of the time, you will be using app access tokens only in server to server calls.
It looks like you have a valid token, you're just trying to query for the current user. If you're using the app token, however, there isn't a current user, so it's failing.
If you are using Java language to fetch app access token, you can try this:
DefaultFacebookClient facebookClient = new DefaultFacebookClient(Version.LATEST);
AccessToken accessToken = facebookClient.obtainAppAccessToken(clientId, clientSecret);
System.out.println(accessToken);
To check whether it is valid, use access token debugger.
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.
I am facing this error with some of my users, the case is as following:
I use facebook "App access token" to post actions to facebook Open Graph instead of the user access token because app access token don't expire according to facebook documentation unless you refreshed the app secret, I use the follwoing Post url to post actions
https://graph.facebook.com/user_facebook_id/App_Namespace:action_name?FBOG_Object=FBOG_OBJECT_URL&access_token=app_access_token
Some of the actions do appear on facebook, but for some users the actions fails to post and return the following message:
{ "error": { "message": "Error validating access token: Session has expired at unix time 1345759200. The current unix time is 1345925578.", "type": "OAuthException", "code": 190, "error_subcode": 463 } }
What am I doing wrong? Why do I have an expiration error although am using the app access token? Should I worry for user permissions?
After checking the servers it seems that the code that uses the app token was not deployed and the code that uses the user token is still there.
The app token does not expire unless the app owner took some action.
https://developers.facebook.com/docs/authentication/applications/
Error message clearly shows that your access token expired and you need to get another one.
However you can handle this issue : Access token expiration
Also if you are looking for a long life token you need to provide some more parameters while authorizing the application to a new user.
offline_access parameter can be included in a request but now it's been deprecated by facebook. Removal of offline access