Answer the question
In order to leave comments, you need to log in
How to check and save data about the principal (user) in the database at the time of authentication?
Hello! I am using Spring Security for OAuth2 authentication on a website. Authentication through Google and Github goes well - protected pages are shown, data about the principal can be extracted. However, it is required to store data about registered users in a local database. How to intercept the moment of authentication and if such a user is not found:
1. transfer to the site page with additional information about the user;
2. write a new user to the database.
Answer the question
In order to leave comments, you need to log in
I used for this
There is a method
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
final OAuth2User oAuth2User = super.loadUser(userRequest);
return new DefaultOAuth2User(appUserAllPermission, attributes, "id");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question