Class GoogleUserInfo
java.lang.Object
com.alpaca.security.oauth2.userinfo.OAuth2UserInfo
com.alpaca.security.oauth2.userinfo.GoogleUserInfo
OAuth2UserInfo implementation for Google OAuth2 provider.
This class extracts user-specific information from the attributes map provided by Google's OAuth2/OpenID Connect userinfo endpoint. It assumes the standard attribute keys returned by Google, including:
- sub: the unique user identifier
- name: the full name
- given_name: the first (given) name
- family_name: the last (family) name
- email: the user's email address
- picture: the user's profile image URL
- email_verified: whether the email address has been verified
By extending OAuth2UserInfo
, this class centralizes how the application accesses
provider-specific user data. It supports safe, consistent access and eases integration when
supporting multiple OAuth2 providers.
These keys align with Google's OpenID Connect specification for its UserInfo endpoint. OpenID Connect spec – Userinfo Endpoint
- See Also:
-
Field Summary
Fields inherited from class com.alpaca.security.oauth2.userinfo.OAuth2UserInfo
attributes
-
Constructor Summary
ConstructorsConstructorDescriptionGoogleUserInfo
(Map<String, Object> attributes) Constructs a new instance from the OAuth2 attributes map. -
Method Summary
Modifier and TypeMethodDescriptiongetEmail()
Returns the user's email addressboolean
Returns true if the user's email is verified; false otherwiseReturns the user's first nameReturns the full name of the usergetId()
Returns the provider-specific unique identifier for the userReturns the URL of the user's profile imageReturns the user's last name
-
Constructor Details
-
GoogleUserInfo
Constructs a new instance from the OAuth2 attributes map.- Parameters:
attributes
- a map of user attributes fetched from Google's UserInfo endpoint
-
-
Method Details
-
getId
Description copied from class:OAuth2UserInfo
Returns the provider-specific unique identifier for the user- Specified by:
getId
in classOAuth2UserInfo
-
getFullName
Description copied from class:OAuth2UserInfo
Returns the full name of the user- Specified by:
getFullName
in classOAuth2UserInfo
-
getFirstName
Description copied from class:OAuth2UserInfo
Returns the user's first name- Specified by:
getFirstName
in classOAuth2UserInfo
-
getLastName
Description copied from class:OAuth2UserInfo
Returns the user's last name- Specified by:
getLastName
in classOAuth2UserInfo
-
getEmail
Description copied from class:OAuth2UserInfo
Returns the user's email address- Specified by:
getEmail
in classOAuth2UserInfo
-
getImageUrl
Description copied from class:OAuth2UserInfo
Returns the URL of the user's profile image- Specified by:
getImageUrl
in classOAuth2UserInfo
-
getEmailVerified
public boolean getEmailVerified()Description copied from class:OAuth2UserInfo
Returns true if the user's email is verified; false otherwise- Specified by:
getEmailVerified
in classOAuth2UserInfo
-