Spring Download OAuth2 connecting internal users with Facebook / Google login

I applied the Spring boot application with AngularJS interface. Also configure users along with their permissions. I can now log in with any of these users and works well with Spring Security. I would like to turn this traditional input stream into a Facebook / Google OAuth login stream, where I want users to use their Facebook / Google account to log in, and they will be automatically mapped to their internal users. This will help me get rid of these users' passwords.

I found many articles about configuring OAuth using Spring Boot and how you can integrate Facebook / Google using the Spring boot application. But it’s hard for me to find an article that talks about the connection of a Facebook / Google user with internal users.

How can I do it?

+7
spring-boot spring-security spring-social google-oauth
source share
2 answers
  • Find the user with the appropriate facebook / google user ID.
  • If this user is not there, you request an email address and try to match it with an existing legacy account.
  • If you did not receive an email address for any reason (for example, without resorting to an authorization request), you can display a pop-up window asking you to specify an email address explaining why you need it.
  • You can then find the legacy user and combine it with the addition of the facebook / google id to find him in the future.
  • If no user is found with an email address, you either refuse the user or create a new account.

you should be able to do all this by implementing your own AuthenticationProvider

+1
source share

Before you can get user data from Facebook, you must specify your application ID and secret by setting the properties spring.social.facebook.appId and spring.social.facebook.appSecret . You can install them using any means supported by Spring Boot, including installing them in the application.properties file:

 spring.social.facebook.appId=233668646673605 spring.social.facebook.appSecret=33b17e044ee6a4fa383f46ec6e28ea1d 

For reference, you can follow this article: https://spring.io/guides/gs/accessing-facebook/

0
source share

All Articles