繁体   English   中英

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

[英]Spring social facebook login - sorry, something went wrong

我正在尝试使用org.springframework.boot:spring-boot-starter-social-facebook在我的spring webapp中实现facebook登录org.springframework.boot:spring-boot-starter-social-facebook ,但每次我按照登录流程我都会在facebook主机上看到这个页面:

错误信息

这是我的设置:

  • 添加了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-930f654f6fd8https://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 client_id 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 xxx 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 response_type 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 code 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 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 732c940f-37fc-406b-b08b-d591e0e372a3 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 redirect_uri 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 3A%2F%2Flocalhost% 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-属性未正确加载导致Facebook对无效的app-idapp-secret表示抱歉。 因此,请确保您的应用ID和密码正常。

2-在Facebook应用仪表板的重定向URI中只需输入http://localhost:8080/然后就可以了。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM