You should try to run and debug existing spring social show-case examples depending on what you need.
See ProviderSignInController class for details.
It had internal private method which looks like:
Code:
private String handleSignIn(Connection<?> connection, NativeWebRequest request, Model model) {
List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
if (userIds.size() == 0) {
ProviderSignInAttempt signInAttempt = new ProviderSignInAttempt(
connection, socialAuthenticationServiceLocator, usersConnectionRepository);
request.setAttribute(ProviderSignInAttempt.SESSION_ATTRIBUTE, signInAttempt, RequestAttributes.SCOPE_SESSION);
return redirect(signUpUrl);
} else if (userIds.size() == 1) {
usersConnectionRepository.createConnectionRepository(userIds.get(0)).updateConnection(connection);
String originalUrl = signInAdapter.signIn(userIds.get(0), connection, request);
return originalUrl != null ? originalUrl : postSignInUrl;
........
Code lines:
if (userIds.size() == 0) {
ProviderSignInAttempt signInAttempt = new ProviderSignInAttempt(connection, socialAuthenticationServiceLocator, usersConnectionRepository);
create real record in UserConnections table when User is authorized by FB for the first time.
Lines:
} else if (userIds.size() == 1) {
usersConnectionRepository.createConnectionReposito ry(userIds.get(0)).updateConnection(connection);
run then User is already known in local UserConnections table and his UC data will be updated by newest info from FB.
The rest of functionality for registering your local Account and other stuff is out of scope those examples, unfortunately.