I'm trying to run the socialauth spring sample (http://code.google.com/p/socialauth/wiki/SpringSample) but when I'm trying to connect with facebook the socialAuthTemplate.getSocialAuthManager() call from SuccessController.java returns null. I can't do any debugging to find out what I do wrong because it's a function from sociaauth.jar and I don't have access to its code. Has anyone had this problem before? What should I do? My only guess is that I didn't configured the project right (I didn't included some library or smth). I'm working with netbeans.
this is the code:
@Controller
public class SuccessController {
@Autowired
private SocialAuthTemplate socialAuthTemplate;
@RequestMapping(value = "/authSuccess")
public ModelAndView getRedirectURL(final HttpServletRequest request)
throws Exception {
ModelAndView mv = new ModelAndView();
List<Contact> contactsList = new ArrayList<Contact>();
SocialAuthManager manager = socialAuthTemplate.getSocialAuthManager(); //returns null
AuthProvider provider = manager.getCurrentAuthProvider();
contactsList = provider.getContactList();
if (contactsList != null && contactsList.size() > 0) {
for (Contact p : contactsList) {
if (!StringUtils.hasLength(p.getFirstName())
&& !StringUtils.hasLength(p.getLastName())) {
p.setFirstName(p.getDisplayName());
}
}
}
mv.addObject("profile", provider.getUserProfile());
mv.addObject("contacts", contactsList);
mv.setViewName("/jsp/authSuccess.jsp");
return mv;
}
Can you verifythe scope of socialAuthTemplate class in your spring config file. It should have session scope.
If you require code base of socialauth, you can download the socialauth-java-sdk-2.3.zip file from following location. It contains all the source code as well as examples.
http://code.google.com/p/socialauth/downloads/list