oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/OAuth2UserRequestEntityConverter.java
@Override
	public RequestEntity<?> convert(OAuth2UserRequest userRequest) {
		ClientRegistration clientRegistration = userRequest.getClientRegistration();

		HttpMethod httpMethod = HttpMethod.GET;
		if (AuthenticationMethod.FORM.equals(clientRegistration.getProviderDetails().getUserInfoEndpoint().getAuthenticationMethod())) {
			httpMethod = HttpMethod.POST;
		}
		HttpHeaders headers = new HttpHeaders();
		headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
		URI uri = UriComponentsBuilder.fromUriString(clientRegistration.getProviderDetails().getUserInfoEndpoint().getUri())
				.build()
				.toUri();

		RequestEntity<?> request;
		if (HttpMethod.POST.equals(httpMethod)) {
			headers.setContentType(DEFAULT_CONTENT_TYPE);
			MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>();
			formParameters.add(OAuth2ParameterNames.ACCESS_TOKEN, userRequest.getAccessToken().getTokenValue());
			request = new RequestEntity<>(formParameters, headers, httpMethod, uri);
		} else {
			headers.setBearerAuth(userRequest.getAccessToken().getTokenValue());
			request = new RequestEntity<>(headers, httpMethod, uri);
		}

		return request;
	}
@Override
	public RequestEntity<?> convert(OAuth2UserRequest userRequest) {
		ClientRegistration clientRegistration = userRequest.getClientRegistration();

		HttpMethod httpMethod = HttpMethod.GET;
		if (AuthenticationMethod.FORM.equals(clientRegistration.getProviderDetails().getUserInfoEndpoint().getAuthenticationMethod())) {
			httpMethod = HttpMethod.POST;
		}
		HttpHeaders headers = new HttpHeaders();
		headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
		URI uri = UriComponentsBuilder.fromUriString(clientRegistration.getProviderDetails().getUserInfoEndpoint().getUri())
				.build()
				.toUri();

		RequestEntity<?> request;
		if (HttpMethod.POST.equals(httpMethod)) {
			headers.setContentType(DEFAULT_CONTENT_TYPE);
			MultiValueMap<String, String> formParameters = new LinkedMultiValueMap<>();
			formParameters.add(OAuth2ParameterNames.ACCESS_TOKEN, userRequest.getAccessToken().getTokenValue());
			request = new RequestEntity<>(formParameters, headers, httpMethod, uri);
		} else {
			headers.setBearerAuth(userRequest.getAccessToken().getTokenValue());
			request = new RequestEntity<>(headers, httpMethod, uri);
		}

		return request;
	}
@ Override public RequestEntity < ? > convert ( OAuth2UserRequest userRequest ) { ClientRegistration clientRegistration = userRequest . getClientRegistration ( ) ; HttpMethod httpMethod = HttpMethod . GET ; if ( AuthenticationMethod . FORM . equals ( clientRegistration . getProviderDetails ( ) . getUserInfoEndpoint ( ) . getAuthenticationMethod ( ) ) ) { httpMethod = HttpMethod . POST ; } HttpHeaders headers = new HttpHeaders ( ) ; headers . setAccept ( Collections . singletonList ( MediaType . APPLICATION_JSON ) ) ; URI uri = UriComponentsBuilder . fromUriString ( clientRegistration . getProviderDetails ( ) . getUserInfoEndpoint ( ) . getUri ( ) ) . build ( ) . toUri ( ) ; RequestEntity < ? > request ; if ( HttpMethod . POST . equals ( httpMethod ) ) { headers . setContentType ( DEFAULT_CONTENT_TYPE ) ; MultiValueMap < String , String > formParameters = new LinkedMultiValueMap <> ( ) ; formParameters . add ( OAuth2ParameterNames . ACCESS_TOKEN , userRequest . getAccessToken ( ) . getTokenValue ( ) ) ; request = new RequestEntity <> ( formParameters , headers , httpMethod , uri ) ; } else { headers . setBearerAuth ( userRequest . getAccessToken ( ) . getTokenValue ( ) ) ; request = new RequestEntity <> ( headers , httpMethod , uri ) ; } return request ; }
Returns the {@link RequestEntity} used for the UserInfo Request.

@param userRequest the user request
@return the {@link RequestEntity} used for the UserInfo Request
Returns the { @link RequestEntity } used for the UserInfo Request .