【问题标题】:Add facebook parameter display=popup when using Spring SocialAuthenticationFilter使用 Spring SocialAuthenticationFilter 时添加 facebook 参数 display=popup
【发布时间】:2017-08-14 06:06:48
【问题描述】:

我需要在弹出窗口中显示 facebook 社交登录。

为了以最少的装饰显示 ​​facebook 登录对话框,我想添加 facebook 参数 display=popup

但我没有使用 Spring Social 的 ConnectController - 在这种情况下,我可以通过拦截器添加参数。

相反,我使用的是 Spring Social 的 SocialAuthenticationFilter。在这种情况下如何添加display=popup

【问题讨论】:

    标签: spring spring-security spring-social spring-social-facebook


    【解决方案1】:

    如果您发布一些用于通过 Facebook 实现身份验证的代码,那将有所帮助。我们正在使用 Spring Social 为我们的网站提供“通过 Facebook 登录功能”。有相关代码:

    ConnectionFactory connectionFactory = connectionFactoryLocator.getConnectionFactory(providerType);
    Method getOAuthOperationsMethod = connectionFactory.getClass().getMethod("getOAuthOperations");
    Object oauthOperations = getOAuthOperationsMethod.invoke(connectionFactory);
    OAuth2Parameters params = new OAuth2Parameters();
    params.setRedirectUri("your redirect URL");
    params.setScope("email");
    params.put("display", Collections.singletonList("popup"));
    params.setState(state);
    authorizeUrl = ((OAuth2Operations) oauthOperations).buildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, params);
    return "redirect:" + authorizeUrl;
    

    authorizeUrl 生成的字符串如下所示:

    https://www.facebook.com/v2.5/dialog/oauth?client_id=1234&response_type=code&redirect_uri=http%3A%2F%2Fwww.company.com%2Fcallback&scope=email&display=popup&state=8fb43b90-be0f-4d3d-9ee6-8cb1641f08b5

    【讨论】:

      猜你喜欢
      • 2015-01-26
      • 2017-01-31
      • 1970-01-01
      • 2013-07-17
      • 2015-03-04
      • 1970-01-01
      • 2011-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多