嗨,我在教程中所做的所有人都喜欢。但我已经停止获取 access_Token。所以这是我重定向到 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);
}
之后在其他控制器中。在 /facebook 上映射的我收到了一个 URL,但在我看到的 url 末尾我找不到任何参数原因#。像
http://localhost:8080/shop/facebook#access_token=.......&expires_in=6277
如果我剪切“#”并粘贴“?” 一切都会好起来的
所以这是我收到此网址的控制器。
@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"));
*/
}
}