当我使用oAuthOperations使用spring社交登录时,这就是我用来设置回调URI的方式。
ConnectionFactoryRegistry registry = (ConnectionFactoryRegistry) conf.connectionFactoryLocator();
FacebookConnectionFactory connectionFactory = (FacebookConnectionFactory)registry.getConnectionFactory( "facebook");
OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();
OAuth2Parameters params = new OAuth2Parameters();
params.setRedirectUri("http://localhost:8080/Social/CallBackFB?au=yes");
String authorizeUrl = oauthOperations.buildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, params);
try
{
response.sendRedirect(authorizeUrl);
}
上面的东西就像魅力一样,但现在我正在使用ProviderSignInController,请告诉我如何设置回调URI,我试图用bean属性设置它。
<bean class="org.springframework.social.connect.web.ProviderSignInController">
<constructor-arg ref="connectionFactoryLocator" />
<constructor-arg ref="usersConnectionRepository" />
<constructor-arg ref="simpleSignInAdapter">
<!-- <bean class="com.controllers.SimpleSignInAdapter" /> -->
</constructor-arg>
<property name="PostSignInUrl"
value="http://localhost:8080/Social/CallBackFB?au=yes" />
</bean>
但我仍然从Facebook获得此回复
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
}
已编辑:Facebook设置
Website with Facebook Login
Site URL: http://localhost:8080/Social/CallBackFB/
App on Facebook
Canvas Page: https://apps.facebook.com/weblikeapp
https://apps.facebook.com/weblikeapp
Canvas URL: http://localhost:8080/Social/CallBackFB/
Secure Canvas URL: https://localhost:8080/Social/CallBackFB/
这不是实际问题,实际问题是此帖的标题!
请告诉我如何正确配置回调我指的是spring-social-quickstart-30x。 https://github.com/spring-projects/spring-social-samples/tree/master/spring-social-quickstart
我想出了如何在facebook中设置回调,现在我正在寻求有关如何在ProviderSigninController中设置URI的帮助。请帮助!
非常感谢!
答案 0 :(得分:1)
您需要在相应的Facebook应用程序(Facebook App Page - &gt; basic tab - &gt;“具有Facebook登录的网站”选项)的设置中允许此回调URL。 Facebook阻止任何将用户重定向到某个不允许的URL的尝试。你目前的问题是在Facebook方面。您无法在Spring Social配置中解决此问题。