Q:

How to get google logged in user's details in spring boot app

I am implementing google login using oauth2 in spring boot app. Now I am stuck, as I don't know how to get user details. Using Authentication or Principal object I can only get  username(which is some random number) with method princial.getname() method and there are no other relevant methods to get the details.

A:

Since the OAuth2 framework is designed to be generic, you will not find methods for anything other than the principal name. 
Instead, the OAuth2User class has a getAttributes method which returns the attributes from the user info uri of the specific provider as a map.
This is how you get the user object of the current request:
@GetMapping("/user/me")
public Map<String, Object> userDetails(@AuthenticationPrincipal OAuth2User user) {
    return user.getAttributes();
}

Try this and you will see which exact attributes google supports.

