I have a requirement in our project to sign-in user using other providers like facebook,google. For this, i am using social auth plugin. it is working fine with facebook,but with googleplus , i am getting error "State parameter value does not match with expected value", this error comes when user redirect in our app after google, means in getUserProfile().so how can i resolve this.
Dependencies are :
runtime "org.brickred:socialauth:4.7"
compile "org.brickred:socialauth:4.7"
my socialauth controller is
def authenticate(){
SocialAuthConfig config = SocialAuthConfig.getDefault()
//You can also pass input stream, properties object or properties file name.
config.load()
//Create an instance of SocialAuthManager and set config
SocialAuthManager manager = new SocialAuthManager()
manager.setSocialAuthConfig(config)
// URL of YOUR application which will be called after authentication
String successUrl = grailsApplication.config.auth.redirect.url
// get Provider URL to which you should redirect for authentication.
// id can have values "facebook", "twitter", "yahoo" etc. or the OpenID URL
String url = manager.getAuthenticationUrl(params.id, successUrl)
session.setAttribute("authManager", manager)
redirect (url:url)
}
@Secured('permitAll')
def getUserProfile(){
try{
// get the auth provider manager from session
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
// Pass request parameter map while calling connect method.
Map<String, String> paramsMap = SocialAuthUtil.getRequestParametersMap(request);
// call connect method of manager which returns the provider object.
AuthProvider provider = manager.connect(paramsMap);
Profile profile = provider.getUserProfile();
log.debug"user profile"+profile
// log.debug"contact"+ provider.getContactList()
}
catch(SocialAuthManagerStateException exception){
log.error("Exception occurs while connecting with SocialAuthManager--->"+exception.getMessage())
}
}
properties file
#googleplus
googleapis.com.consumer_key = XXXXXXXXXXXXXX
googleapis.com.consumer_secret = XXXXXXXXXXXXXXX
This is the problem with Version , you can use social auth 4.6 , it works fine