Extracting name from Google, Facebook
Spring Lemon provides a DefaultPrincipalExtractor
, which extracts user data from social providers such as Google and Facebook when a user signs in/up using her social account.
Now that we have added name
to our users, we need to extend DefaultPrincipalExtractor
and override one of its methods. So, create a MyDefaultPrincipalExtractor
class as below:
@Component
public class MyDefaultPrincipalExtractor extends DefaultPrincipalExtractor<User> {
protected void fillAdditionalFields(User user, Map<String, Object> map) {
user.setName((String) map.get("name"));
}
}