I am trying to retrieve the data feed from a closed facebook group trough server-to-server call using graph api v2.8.
The access token is obtained by configuring my OAuth 2.0 provider with the following parameters:
OAuth2ClientOptions credentials = new OAuth2ClientOptions()
.setClientID(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setSite("https://www.facebook.com")
.setAuthorizationPath("/dialog/oauth")
.setTokenPath("https://graph.facebook.com/oauth/access_token");
CLIENT_ID and CLIENT_SECRET values are received from facebook after registering a new application there.
The response I get from the facebook server (graph.facebook.com) is:
{
"error": {
"message": "Unsupported get request. Object with ID '...' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "D91Fkk/Gmx8"
}
}
The same code can be successfully used to access an OPEN facebook group. In addition, there is no problem to read the data inside the CLOSED group from Graph API Explorer using a user token. Seems to be security problem.
How can I configure the permissions of my facebook application so that I can reach the data also inside a CLOSED group?
Regards,
Mihail
I assume that you are not an Admin/Moderator of the group. Afaik you can only read posts of a closed group with a User token of a Moderator.
An App Token cannot work for this, there is no relation to any User. You MUST use a User Token.
Related
I'm trying to use this endpoint from the Instagram graph api:
GET /ig_hashtag_search?user_id={user-id}&q={q}
Documentation for this endpoint can be found here.
I'm running this GET request:
https://graph.facebook.com/v14.0/ig_hashtag_search?q=coke&transport=cors&user_id=<my_user_id>&access_token=<my_access_token>&q=coke
and get this as response:
{
"error": {
"message": "(#200) Requires instagram_basic permission to manage the object",
"type": "OAuthException",
"code": 200,
}
}.
The user id comes from my instagram account and the access_token that I'm using is a User token generated with "Graph API explorer" and I can see that this token has the scope "instagram_basic" when using the "Access Token Debugger".
I can't understand why this does not work? Do I really need to submit a API review just to test the hashtag endpoint during development?
Please help!
I guess sometimes App review team of Facebook doesn't know what is the usage of the permission so they just decline the submissions randomly. I got that permission like 3 months ago and i checked my app review. I send them this text
We are going to use instagram_basic to read an Instagram account profile's info and media. We will get the basic metadata of an Instagram Business account profile like "USERNAME", "ID", "FOLLOWERS", "FOLLOWING". You can check the Screescast to see how we use the instagram_basic on our app.
Here is what they saw while they do the app review
Also be careful while you send requests, keep in mind to change it to development mode. Some of the endpoints works only in live mode. The API still changes a lot and there are tons of bugs i see in my project. I hope this helps.
While working with the Facebook Workplace API liking an object (post, comment, photo..etc) can be done by passing the Admin Access Token, I'm trying to figure out how to do it on behalf on the user for a feed / comment posted into a group.
The docs mention getting the Page Access Token to perform this action but a Group doesn't have an Access Token & doesn't really solve what I'm going for anyway.
I've tried getting the User Impersonation Token from the API using the Admin Token but posting to the likes graph endpoint results in a publishing error.
POST /https://graph.facebook.com/{COMMENT-ID or POST-ID}/likes
HEADERS: Authorization Bearer "{IMPERSONATION-TOKEN}"
Error Response:
{
"error": {
"message": "(#3) Publishing likes through the API is only available for page access tokens",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "CGpXtFWrwiA"
}
}
Again this works fine using the Admin App Access Token but not on behalf of the user. Also a group doesn't have an access token unlike a regular FB Page.
Any help on this would be great!
I need to access Facebook API to retrieve ads stats. All my requests will be handled on server side. I already know how to access those data by obtaining User Access Token with ads_read permission, where user has admin role in the ad account.
My application will use cron jobs to retrieve ads stats, so I would like to use App Access Token instead, because user won't need to authenticate with the dialog, right? I assigned application to the business, but it doesn't seem to work. After trying to get ads stats with App Access Token, I'm getting following error:
{
"error": {
"message": "The entity backed by id 1234567890123 cannot be seen
by the viewer with (ViewerID 0, AccountID 0):
DENY_RULE:InlinePrivacyPolicy:AlwaysDenyRule:4
(EntID: 1234567890123)",
"type": "OAuthException",
"code": 1
}
}
The application is assigned to the business, but I'm not sure if it's enough. I don't see any option to assign it to the ads account.
Am I doing it right or maybe there's another way to skip dialog part?
No, you need to use a user access token from a user who manages the ad account.
App access tokens are only useful for a narrow range of use cases, primarily for updating app settings or proving a call came from the app specifically, rather than an arbitrary user of the app
Following the Ads API docs for reachestimate (http://developers.facebook.com/docs/reference/ads-api/reachestimate/), I received a "false" response when calling
https://graph.facebook.com/act_0000000000000000/reachestimate?currency=EUR&targeting_spec={'countries':['US']}&access_token=___
(Note: act_0000000000000000 is my user Id and _ is my access token - these tokens work correctly for other Ads API calls).
Using the Graph API Explorer tool, I receive the following response on this API call
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10
}
}
However, when I call
https://graph.facebook.com/1111111111111111/reachestimate?currency=EUR&targeting_spec={'countries':['US']}&access_token=___
where 1111111111111111 is an adgroup, I get a valid data structure.
Has anyone come across this elsewhere? Is there a "magic" setting somewhere that enables this capability on the user account (enabled for ads_management, offline_access)?
Any thoughts very welcome.
Thank you.
Thanks #Igy - just confirmed that my issue was indeed the misuse of my UserID in account field - have since migrated these queries to use the designated account ID and works as expected.
I am using graph API to get the feed post.
https://graph.facebook.com/128172073865656/feed?limit=200
but it is showing exception
{
"error": {
"type": "OAuthException",
"message": "An access token is required to request this resource."
}
}.
Could any one please help.
Quite simply, you need to obtain and supply an access token with your request.
In particular, the Graph API connections that you're trying to load have been changed recently, and now require an access_token, where they previously did not.
See the Facebook Developer Blog, posts on this:
https://developers.facebook.com/blog/post/509/ - Notification of change in requirements.
https://developers.facebook.com/blog/post/510/ - Confirmation that the changes are now live.