Hi 2 all guys i make all like in tutorial. But i have stopped on getting access_Token. So this is my code that redirect to facebook.
@RequestMapping(method = RequestMethod.GET)
public void process(/*
* @ModelAttribute("user") User user, BindingResult
* result Model model,
*/HttpServletRequest request, HttpServletResponse response) {
FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory("240362226072898", "657532dea6d091ab44a56668c47cca15");
OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();
OAuth2Parameters params = new OAuth2Parameters("http://localhost:8080/shop/facebook");
String authorizeUrl = oauthOperations.buildAuthorizeUrl(GrantType.IMPLICIT_GRANT, params);
try {
response.sendRedirect(authorizeUrl);
LOG.error("ALL WORKING FINE>>>");
} catch (IOException e) {
LOG.error("Errorrrrr" + e);
}
After that in other controller. which mapped on /facebook i recieve an URL but there i can not find any parametrs cause at the end of the url i see #. like
http://localhost:8080/shop/facebook#access_token=.......&expires_in=6277
if i cut “#” and paste “?” there everything will be fine
so this is my controller where i recieve this url.
@Controller
@RequestMapping(value = "/facebook")
public class FacebookController {
private static final Logger LOG = Logger.getLogger(FacebookController.class);
@RequestMapping(method = RequestMethod.GET)
public void getAuthorisation(@RequestParam String access_token, HttpServletResponse response, HttpServletRequest request) {
LOG.error("Access token"+access_token);
/* LOG.error(request.getAttribute("access_token"));
LOG.error(request.getParameter("access_token"));
*/
}
}
Extract the access token from the URI fragment using Javascript.
See the documentation for client side flow: