Integrate Spring Security with Facebook Login

别来无恙 提交于 2019-12-03 16:55:51

I don't think you should deal with Facebook manually. You can a really easy library: https://github.com/pac4j/spring-security-pac4j to authenticate for OAuth (Facebook, Twitter, Google...), CAS, SAML, OpenID (Connect) and GAE. See the demo: https://github.com/pac4j/spring-security-pac4j-demo

Daniel could you please elaborate where are you getting stuck. I used the same stack for integrating facebook login. But I did not use Spring Social. I believe it's not required.

Steps to integrate facebook login with the existing login.

  1. Use the facebook javascript plugin in your jsp for facebook login.
  2. Once the user approves your app. OAuth generates an auth token, using that fetch the email id of the client using graph API.
  3. Send the email id to the server using Ajax.
  4. Compare the email id sent to the server side with the email id in the database.
  5. If the email id is same login the user.

Authentication token is temporary so I find it pointless sending it to the server side or saving in db. It is saved locally on the client side. And the fb javascript plugin takes care of it. This way it saves you the hassle of implementing spring social facebook.

I see you are using the controller for facebook login, it's not required, trust me using the fb javascript plugin is really simple & easy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!