Spring社交facebook登录 - 抱歉,出了点问题

时间:2016-11-26 13:34:47

标签: java spring facebook oauth spring-social-facebook

我正在尝试使用org.springframework.boot:spring-boot-starter-social-facebook在我的春季网络应用程序中实现facebook登录,但是每次按照登录流程我都会在facebook主机上获得此页面:

Error message

这是我的设置:

  • 添加了appId和secret:

application.properties

spring.social.facebook.appId=xxx
spring.social.facebook.appSecret=xxx
  • 在Facebook开发者页面中,我启用了 facebook登录产品,并添加了http://localhost:8080/connect/facebook作为我的重定向uri。

  • 写了一个登录表:

连接/ facebook.html

<form th:action="@{/connect/facebook}" method="POST">
    <input type="hidden" name="scope" value="user_posts"/>
    <button type="submit">Connect to Facebook</button>
</form>

将我重定向到此网址: https://www.facebook.com/v2.3/dialog/oauth?client_id=xxx&response_type=code&_csrf=732c940f-37fc-406b-b08b-d591e0e372a3&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fconnect%2Ffacebook&scope=user_posts&state=8ec3aaa3-972e-401e-b47f-930f654f6fd8

我认为这里不需要_csrf来自spring的csrf注入器,但它无论如何都不应该有任何区别。

有谁知道如何解决这个问题?错误消息根本不详细,我不知道在哪里可以开始故障排除。

1 个答案:

答案 0 :(得分:0)

我也遇到过这个问题,在我的案例中

1-属性未正确加载导致Facebook对无效app-idapp-secret表示抱歉。因此,请确保您的应用ID和密码正常。

2-在Facebook应用仪表板中重定向URI只需添加http://localhost:8080/ 它应该工作。

有关更多帮助和指导,您可以查看我创建的github项目,因为使用Spring Social时会遇到大多数问题。

相关问题