This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

How to fetch group list from facebook using spring social facebook?Page Title Module

You are correct in your diagnosis: You created FacebookTemplate without specifying an access token. In order to use many of the operations provided by FacebookTemplate, you must have an authorized access token.

There are several ways to get an authorized access token, but I recommend that you have a look at what Spring Social's ConnectController offers you (all of the details are in the documentation and demonstrated in the samples). It is especially useful if you are building a web application, as it handles all of the browser redirection required by Facebook's authorization flow.

If you're not building a web application, there are other means by which you can get an access token, but which one you choose largely depends on your application.

Comment

I may be a bit puzzled by what you've done here...but it appears that you're working with a Facebook object given to you via a Connection (like how it is done in the showcase sample). If so, then you should know that there is still an access token involved, but it was handled for you under the covers. By working with Spring Social's connection framework, you never have to deal with the access token or any of the OAuth2 stuff--the framework handles all of that for you.

So, since an access token is still involved, you should be able to do anything with Facebook API that the access token is authorized to do.

What puzzles me a bit more, though is that the Facebook interface doesn't have a fetchConnections() method. That's a lower level method used within FacebookTemplate (typically you'd use the higher-level methods in the interfaces given through Facebook methods). You're welcome to use it as you have, but I'm confused as to how you're using it with the Facebook interface, unless you're casting to FacebookTemplate.

Also, I just noticed that you're asking for the groups of the current user. I don't believe that the API binding supports this in its higher-level API interfaces. I've created https://jira.springsource.org/browse/SOCIALFB-49 to add it to the API binding. In the meantime, you can still access it through the lower level fetchConnections() method as you've done.