FacebookGraphException when using obtainAppAccessToken

46 views
Skip to first unread message

Carlos Obregón

unread,
Oct 3, 2017, 12:39:03 AM10/3/17
to RestFB
I was doing some coding today using this code without a problem:

private static List<Post> getPosts(final String pageId, final String id, final String secret) {
   FacebookClient.AccessToken accessToken = new DefaultFacebookClient().obtainAppAccessToken(id, secret);
FacebookClient client = new DefaultFacebookClient(accessToken.getAccessToken(), Version.VERSION_2_10);
Connection<Post> pageFeed = client.fetchConnection(pageId + "/feed", Post.class);
Iterator<List<Post>> feed = pageFeed.iterator();
List<Post> allPosts = feed.hasNext() ? feed.next() : Collections.emptyList();
return allPosts;
}

And then it suddenly stopped working and began throwing a FacebookGraphException. After a little bit of digging I found that accessToken.getAccessToken() was returning an odd String which certainly doesn't look like a valid access token. I tried using that in the API Graph Explorer that FB provides and obviously it doesn't work.  Reading restfb and Facebook's documentation I can't find a clear answer on how obtainAppAccessToken can return a token that's not valid.

Can someone shed some light here?

Thanks

Norbert Bartels

unread,
Oct 4, 2017, 10:09:19 AM10/4/17
to RestFB
Can you please set the logging to DEBUG and check the calls and responses?

THX
Norbert

Carlos Obregón

unread,
Oct 4, 2017, 9:21:35 PM10/4/17
to RestFB
This is the error I'm getting:

Received Facebook error response of type GraphMethodException: Unsupported get request. Object with ID 'XXX' 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 (code 100, subcode 33)

It seems there's something in the configuration of my application that is not correctly set but documentation is really bad about this issue.
Reply all
Reply to author
Forward
0 new messages