Source:
<code>public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { Assert.notNull(userRequest, "userRequest cannot be null"); if (!StringUtils.hasText(userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUri())) { OAuth2Error oauth2Error = new OAuth2Error( MISSING_USER_INFO_URI_ERROR_CODE, "Missing required UserInfo Uri in UserInfoEndpoint for Client Registration: " + userRequest.getClientRegistration().getRegistrationId(), null ); throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } <START> UserInfoRequestSchema userInfoRequestSchema = userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUserInfoRequestSchema(); <END> if (userInfoRequestSchema == null) { OAuth2Error oauth2Error = new OAuth2Error( MISSING_USER_INFO_REQUEST_SCHEMA_ERROR_CODE, "Missing required UserInfo UserInfoRequestSchema in UserInfoEndpoint for Client Registration: " + userRequest.getClientRegistration().getRegistrationId(), null ); throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } String userNameAttributeName = userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUserNameAttributeName(); if (!StringUtils.hasText(userNameAttributeName)) { OAuth2Error oauth2Error = new OAuth2Error( MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE, "Missing required \"user name\" attribute name in UserInfoEndpoint for Client Registration: " + userRequest.getClientRegistration().getRegistrationId(), null ); throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } ParameterizedTypeReference<Map<String, Object>> typeReference = new ParameterizedTypeReference<Map<String, Object>>() {}; Map<String, Object> userAttributes = this.userInfoResponseClient.getUserInfoResponse(userRequest, typeReference); GrantedAuthority authority = new OAuth2UserAuthority(userAttributes); Set<GrantedAuthority> authorities = new HashSet<>(); authorities.add(authority); return new DefaultOAuth2User(authorities, userAttributes, userNameAttributeName); }</code><technical_language>If user configured authenticationMethod default HEADER. this check needed</technical_language>

Target:
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { Assert.notNull(userRequest, "userRequest cannot be null"); if (!StringUtils.hasText(userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUri())) { OAuth2Error oauth2Error = new OAuth2Error( MISSING_USER_INFO_URI_ERROR_CODE, "Missing required UserInfo Uri in UserInfoEndpoint for Client Registration: " + userRequest.getClientRegistration().getRegistrationId(), null ); throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } String userNameAttributeName = userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUserNameAttributeName(); if (!StringUtils.hasText(userNameAttributeName)) { OAuth2Error oauth2Error = new OAuth2Error( MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE, "Missing required \"user name\" attribute name in UserInfoEndpoint for Client Registration: " + userRequest.getClientRegistration().getRegistrationId(), null ); throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } ParameterizedTypeReference<Map<String, Object>> typeReference = new ParameterizedTypeReference<Map<String, Object>>() {}; Map<String, Object> userAttributes = this.userInfoResponseClient.getUserInfoResponse(userRequest, typeReference); GrantedAuthority authority = new OAuth2UserAuthority(userAttributes); Set<GrantedAuthority> authorities = new HashSet<>(); authorities.add(authority); return new DefaultOAuth2User(authorities, userAttributes, userNameAttributeName); }