In order to save the provider details, we need to fetch the available details from the provider, available via the OAuth 2 connection. Next, we create a CalendarUser table from the available details. Note that we need to create at least one GrantedAuthority role. Here, we have used CalendarUserAuthorityUtils#createAuthorities to create ROLE_USER GrantedAuthority:
//src/main/java/com/packtpub/springsecurity/authentication/
ProviderConnectionSignup.java
@Service
public class ProviderConnectionSignup implements ConnectionSignUp {
...
@Override
public String execute(Connection<?> connection) {
UserProfile profile = connection.fetchUserProfile();
CalendarUser user = new CalendarUser();
if(profile.getEmail() != null){
user.setEmail(profile.getEmail());
}
...