spring-social - Spring Social 在身份验证时获取用户电子邮件

标签 spring-social

我们正在使用 spring-social 将我们的应用程序集成到 Facebook。 在 OAuth2AuthenticationService 中,范围为空。 我们将范围设置为表单上的输入。但这不起作用,并且无法设置范围。 我们无法获取用户电子邮件。

有什么方法可以覆盖“OAuth2AuthenticationService”范围变量吗?

不是:Spring 社交版本是 1.1.0.BUILD-SNAPSHOT

We used spring social sample which contains security xml version

            <form name="fb_signin" id="fb_signin" action="../auth/facebook"
                method="post">
                <input type="hidden" name="scope"
                    value="email,publish_stream,read_stream,offline_access" /> 
                <button type="submit"> <img src="../images/social/facebook/sign-in-with-facebook.png" /> </button>  
                <!--  
                <input
                    type="image"
                    src="../images/social/facebook/sign-in-with-facebook.png"
                    align="right" />
                --> 
            </form>

最佳答案

在您的配置中,您需要将 scope 指定为 FacebookAuthenticationService 的属性。这是处理对 auth/facebook

调用的服务

在 XML 配置中,而不是:

<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}"/>

用途:

<bean id="connectionFactoryLocator" class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
    <property name="authenticationServices">
        <list>
            <bean class="org.springframework.social.facebook.security.FacebookAuthenticationService">
                <constructor-arg value="${facebook.clientId}" />
                <constructor-arg value="${facebook.clientSecret}" />
                <property name="scope" value="email" />              
            </bean>
        </list>
    </property>
</bean>

这适用于 Spring Social 1.1.0.M3

关于spring-social - Spring Social 在身份验证时获取用户电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17110874/

相关文章:

spring - 确定 Spring Social 中的连接类型

java - Facebook 的 Spring 社交授权异常

java - 配置 Spring Social 以提供静态内容

java - SpringSocial LinkedIn 集成错误

java - 如何在 MVC 配置中允许匿名 Twitter 连接

facebook - Grails Facebook Spring Security返回null

Spring Social Twitter 通过推文 id 搜索?

spring - 如何通过 REST API 为 Spring-social 和 spring-security 设置登录服务?

facebook - Spring Social 从 facebook 获取数据

facebook - Spring Social Facebook 中的 UsersConnectionRepository 是什么?