使用Spring Socail的Twitter授权

时间:2018-07-26 18:30:36

标签: java spring spring-security backend spring-social

我们正在尝试使用Spring Social授权Twitter,但出现以下错误。 “异常处理模板“ connect / twitterConnect”:解决模板“ connect / twitterConnect”时出错,该模板可能不存在,或者任何已配置的模板解析器都无法访问该模板”

控制器

      @RequestMapping(value = "/twitter", method = RequestMethod.GET)
      public String loginToTwitter(Model model) {
      System.out.println("Here in loginToTwitter");
      return twitterProvider.getTwitterUserData(model, new UserBean());

TwiiterProvide类

    @Service
    public class TwitterProvider {

    private static final String TWITTER = "twitter";
    private static final String REDIRECT_LOGIN = "redirect:/login";

    @Autowired
    BaseProvider baseProvider;

    public String getTwitterUserData(Model model, UserBean userForm) {
    ConnectionRepository connectionRepository = 
    baseProvider.getConnectionRepository();
    System.out.println("May be Here");
    System.out.println((connectionRepository ==null));
    if (connectionRepository.findPrimaryConnection(Twitter.class) == null) {
    return REDIRECT_LOGIN;
    }
    model.addAttribute("loggedInUser",userForm);
    return "user";
    }

0 个答案:

没有答案