简体   繁体   中英

Spring social facebook login - sorry, something went wrong

I'm trying to implement facebook login in my spring webapp using org.springframework.boot:spring-boot-starter-social-facebook , However everytime I follow the login flow I get this page at facebook host:

错误信息

Here's my setup:

  • Added appId and secret:

application.properties

spring.social.facebook.appId=xxx
spring.social.facebook.appSecret=xxx
  • In facebook developer page I enabled facebook login product and added http://localhost:8080/connect/facebook as my redirect uri.

  • Wrote a login form:

connect/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>

That redirects me to this url: 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

I think that _csrf is not required here and came from spring's csrf injector, but it shouldn't make any difference anyway.

Does anyone know how to resolve this? The error message is not verbose at all and I'm not sure where can I start troubleshooting.

I also faced this issue, in my case

1- Property was not being loaded correctly which causes facebook to say Sorry against invalid app-id and app-secret . So make sure your app id and secret are OK.

2- In redirect URI from facebook app dashboard just put http://localhost:8080/ then it should work.

For more help and guide, you can check github project I created due to such issues faced by majority while using Spring Social.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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