Spring Social Facebook URL Redirect on another server -


i'm new on spring social api, i'm trying login application facebook, it's not redirecting me domain url.

my application running on 2 servers, based on restcontroller ajax form submitted. 1 apache web server , 1 tomcat server.

but not facebook authentication based on restcontroller, if user need login facebook id can click on login facebook button , page redirecting facebook login pate, not redirect requested url.

my code under:

login facebook

@requestmapping(value = "/fbauth", method = requestmethod.get) public void fbredirect(@requestparam map requestparams) throws unsupportedencodingexception { string accesstoken = null; // string accesstoken = // "caafv5tfcxvsbamkgz7mz63esclek3jgzbezazbqlj3capiyqmva5hortl9ln05o3brtcx95tjt9ixzbfrz3fkzbjnj74qko1sfjjzaxmddnzvepmgxswom8nhegtza6aub7bnzbybimo2zbxx2gpo6ky7dkqu2xzbuymaalagg3ixarqme3e3w1ruutveyqrtmb3x0pehhoiatqzdzd"; resttemplate resttemplate = new resttemplate(); map result = null; if (stringutils.isempty(accesstoken)) { (string key : requestparams.keyset()) { object value = requestparams.get(key); logger.info("key: " + key + " value: " + value); }

        string code = requestparams.get("code");         if (stringutils.isnotempty(code)) {             string authurl = "http://" + request.getservername() + "/realtybud/fbauth";             stringbuilder stringbuilder = new stringbuilder();             string fbauthapi = "https://graph.facebook.com/v2.3/oauth/access_token?client_id=";             stringbuilder.append(fbauthapi);             stringbuilder.append(selectappid());             stringbuilder.append("&redirect_uri=");             stringbuilder.append(authurl);             stringbuilder.append("&client_secret=");             stringbuilder.append(selectappsecret());             stringbuilder.append("&code=");             stringbuilder.append(code);             string fbgraphurl = stringbuilder.tostring();              result = resttemplate.getforobject(fbgraphurl, map.class);             accesstoken = result.get("access_token");             logger.info("access token: " + accesstoken);         }     }      stringbuilder stringbuilder = new stringbuilder();     string fbgraphapi = "https://graph.facebook.com/v2.3/me?fields=id,name,email&access_token=";     stringbuilder.append(fbgraphapi);     stringbuilder.append(accesstoken);     string fbprofileinfo = stringbuilder.tostring();     // string info = resttemplate.getforobject(fbprofileinfo, string.class);     // logger.info("info: " + info);     map<string, string> info = resttemplate.getforobject(fbprofileinfo, map.class);     logger.info("id: " + info.get("id") + " name: " + info.get("name") + " email: " + info.get("email"));     string email = info.get("email");     if (stringutils.isnotempty(email)) {         user user = userservice.finduserbyemail(email);         if (user == null) {             user = new user();             user.setemail(email);             user.setfacebookaccesstoken(accesstoken);             user.setfacebookname(info.get("name"));             userservice.usersave(user);              role userrole = new role();             userrole.setrolename("role_user");             userrole.setuser(user);             userservice.rolesave(userrole);              list<role> roles = new arraylist<role>();             roles.add(userrole);             user.setroles(roles);         } else {             user.setfacebookaccesstoken(accesstoken);             user.setfacebookname(info.get("name"));             userservice.usersave(user);         }          securityuser secuser = new securityuser(user);         authentication authentication = new usernamepasswordauthenticationtoken(secuser, secuser.getpassword(),                 secuser.getauthorities());         securitycontextholder.getcontext().setauthentication(authentication);      } else {         // error     }      // string fbauthsuccessurl = "/index?fbauth=success";     //return "redirect:/"; } 

please me how can redirect apache web server login credentials.

thanks in advance. waqas

i solved problem changing redirect url in web server (nginx in case), don't know best way (or appropriate) or not!


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -