Class CustomOAuth2UserService

  • All Implemented Interfaces:
    org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,​org.springframework.security.oauth2.core.user.OAuth2User>

    @Service
    public class CustomOAuth2UserService
    extends java.lang.Object
    implements org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,​org.springframework.security.oauth2.core.user.OAuth2User>
    This is a copy of DefaultOAuth2UserService but using .get("data") to get userAttributes. As happens with Coinbase, for example.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.security.oauth2.core.user.OAuth2User loadUser​(org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest userRequest)  
      void setRequestEntityConverter​(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,​org.springframework.http.RequestEntity<?>> requestEntityConverter)
      Sets the Converter used for converting the OAuth2UserRequest to a RequestEntity representation of the UserInfo Request.
      void setRestOperations​(org.springframework.web.client.RestOperations restOperations)
      Sets the RestOperations used when requesting the UserInfo resource.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomOAuth2UserService

        public CustomOAuth2UserService()
    • Method Detail

      • loadUser

        public org.springframework.security.oauth2.core.user.OAuth2User loadUser​(org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest userRequest)
                                                                          throws org.springframework.security.oauth2.core.OAuth2AuthenticationException
        Specified by:
        loadUser in interface org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,​org.springframework.security.oauth2.core.user.OAuth2User>
        Throws:
        org.springframework.security.oauth2.core.OAuth2AuthenticationException
      • setRequestEntityConverter

        public final void setRequestEntityConverter​(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,​org.springframework.http.RequestEntity<?>> requestEntityConverter)
        Sets the Converter used for converting the OAuth2UserRequest to a RequestEntity representation of the UserInfo Request.
        Parameters:
        requestEntityConverter - the Converter used for converting to a RequestEntity representation of the UserInfo Request
        Since:
        5.1
      • setRestOperations

        public final void setRestOperations​(org.springframework.web.client.RestOperations restOperations)
        Sets the RestOperations used when requesting the UserInfo resource.

        NOTE: At a minimum, the supplied restOperations must be configured with the following:

        1. ResponseErrorHandler - OAuth2ErrorResponseErrorHandler
        Parameters:
        restOperations - the RestOperations used when requesting the UserInfo resource
        Since:
        5.1