java with Oauth for Google and facebook authontication
i wont to implement authentication using google and facebook in my application any one share example that work for authentication in java webapp without any java framework
i try with socialau开发者_JAVA技巧t its using struts and spring framework but i not use that framework in my application so give any example that work in simple tomcat application without any framework
add this code on login page request
SocialAuthConfig config = SocialAuthConfig.getDefault();
config.load(); // load your keys information
SocialAuthManager manager = new SocialAuthManager();
manager.setSocialAuthConfig(config);
String successUrl = "http://localhost:8080/yourapp/status
String url = manager.getAuthenticationUrl("facebook", successUrl);
session.setAttribute("authManager", manager);
redirect yout page to url for authentication
add this code on /status url
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
AuthProvider provider = manager.connect(paramsMap);
// get profile
Profile p = provider.getUserProfile();
// you can obtain profile information
System.out.println(p.getFirstName());
// OR also obtain list of contacts
List<Contact> contactsList = provider.getContactList();
精彩评论