I'm building a login module where you can login with all kinds of social network accounts. The initial step is LinkedIn and Google.
The LinkedIn part is working fine, but the Google part isn't. I think the problem is with my code BEFORE the authentication, because the return url has openid parameters, instead of OAuth parameters. This is the code before the redirect:
HttpSession session = request.getSession();
SocialAuthConfig config = SocialAuthConfig.getDefault();
try {
config.load("/oauth_consumer.properties");
} catch (Exception ex) {
System.out.println(ex);
}
//Create an instance of SocialAuthManager and set config
SocialAuthManager manager = new SocialAuthManager();
try {
manager.setSocialAuthConfig(config);
} catch (Exception ex) {
System.out.println(ex);
}
//URL of YOUR application which will be called after authentication
String successUrl = "http://localhost:8080/ProjectName/completelogin.do";
String url = "";
try {
url = manager.getAuthenticationUrl(type, successUrl).toString();
} catch (Exception ex) {
System.out.println(ex);
}
// Store in session
session.setAttribute("authManager", manager);
response.sendRedirect(url);
And this is my oauth_consumer.properties part for google
www.google.com.consumer_key = 81XXXXXX466.apps.googleusercontent.com
www.google.com.consumer_secret = WN0oXXXXXXXHoCeSocQK
www.google.com.custom_permissions=https://www.googleapis.com/auth/userinfo.profile,https://www.googleapis.com/auth/userinfo.email
Can I force Google to use OAuth authentication in stead of OpenID authentication? I've logged onto google with another framework using OAuth and it worked like a charm. Only now, since I want to use several social sites, I don't want to keep reinventing the wheel and just use socialauth...