oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistrations.java
public static ClientRegistration.Builder fromOidcIssuerLocation(String issuer) {
		String openidConfiguration = getOpenidConfiguration(issuer);
		OIDCProviderMetadata metadata = parse(openidConfiguration);
		String metadataIssuer = metadata.getIssuer().getValue();
		if (!issuer.equals(metadataIssuer)) {
			throw new IllegalStateException("The Issuer \"" + metadataIssuer + "\" provided in the OpenID Configuration did not match the requested issuer \"" + issuer + "\"");
		}

		String name = URI.create(issuer).getHost();
		ClientAuthenticationMethod method = getClientAuthenticationMethod(issuer, metadata.getTokenEndpointAuthMethods());
		List<GrantType> grantTypes = metadata.getGrantTypes();
		// If null, the default includes authorization_code
		if (grantTypes != null && !grantTypes.contains(GrantType.AUTHORIZATION_CODE)) {
			throw new IllegalArgumentException("Only AuthorizationGrantType.AUTHORIZATION_CODE is supported. The issuer \"" + issuer + "\" returned a configuration of " + grantTypes);
		}
		List<String> scopes = getScopes(metadata);
		Map<String, Object> configurationMetadata = new LinkedHashMap<>(metadata.toJSONObject());

		return ClientRegistration.withRegistrationId(name)
				.userNameAttributeName(IdTokenClaimNames.SUB)
				.scope(scopes)
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.clientAuthenticationMethod(method)
				.redirectUriTemplate("{baseUrl}/{action}/oauth2/code/{registrationId}")
				.authorizationUri(metadata.getAuthorizationEndpointURI().toASCIIString())
				.jwkSetUri(metadata.getJWKSetURI().toASCIIString())
				.providerConfigurationMetadata(configurationMetadata)
				.userInfoUri(metadata.getUserInfoEndpointURI().toASCIIString())
				.tokenUri(metadata.getTokenEndpointURI().toASCIIString())
				.clientName(issuer);
	}
public static ClientRegistration.Builder fromOidcIssuerLocation(String issuer) {
		String openidConfiguration = getOpenidConfiguration(issuer);
		OIDCProviderMetadata metadata = parse(openidConfiguration);
		String metadataIssuer = metadata.getIssuer().getValue();
		if (!issuer.equals(metadataIssuer)) {
			throw new IllegalStateException("The Issuer \"" + metadataIssuer + "\" provided in the OpenID Configuration did not match the requested issuer \"" + issuer + "\"");
		}

		String name = URI.create(issuer).getHost();
		ClientAuthenticationMethod method = getClientAuthenticationMethod(issuer, metadata.getTokenEndpointAuthMethods());
		List<GrantType> grantTypes = metadata.getGrantTypes();
		// If null, the default includes authorization_code
		if (grantTypes != null && !grantTypes.contains(GrantType.AUTHORIZATION_CODE)) {
			throw new IllegalArgumentException("Only AuthorizationGrantType.AUTHORIZATION_CODE is supported. The issuer \"" + issuer + "\" returned a configuration of " + grantTypes);
		}
		List<String> scopes = getScopes(metadata);
		Map<String, Object> configurationMetadata = new LinkedHashMap<>(metadata.toJSONObject());

		return ClientRegistration.withRegistrationId(name)
				.userNameAttributeName(IdTokenClaimNames.SUB)
				.scope(scopes)
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.clientAuthenticationMethod(method)
				.redirectUriTemplate("{baseUrl}/{action}/oauth2/code/{registrationId}")
				.authorizationUri(metadata.getAuthorizationEndpointURI().toASCIIString())
				.jwkSetUri(metadata.getJWKSetURI().toASCIIString())
				.providerConfigurationMetadata(configurationMetadata)
				.userInfoUri(metadata.getUserInfoEndpointURI().toASCIIString())
				.tokenUri(metadata.getTokenEndpointURI().toASCIIString())
				.clientName(issuer);
	}
public static ClientRegistration . Builder fromOidcIssuerLocation ( String issuer ) { String openidConfiguration = getOpenidConfiguration ( issuer ) ; OIDCProviderMetadata metadata = parse ( openidConfiguration ) ; String metadataIssuer = metadata . getIssuer ( ) . getValue ( ) ; if ( ! issuer . equals ( metadataIssuer ) ) { throw new IllegalStateException ( "The Issuer \"" + metadataIssuer + "\" provided in the OpenID Configuration did not match the requested issuer \"" + issuer + "\"" ) ; } String name = URI . create ( issuer ) . getHost ( ) ; ClientAuthenticationMethod method = getClientAuthenticationMethod ( issuer , metadata . getTokenEndpointAuthMethods ( ) ) ; List < GrantType > grantTypes = metadata . getGrantTypes ( ) ; // If null, the default includes authorization_code if ( grantTypes != null && ! grantTypes . contains ( GrantType . AUTHORIZATION_CODE ) ) { throw new IllegalArgumentException ( "Only AuthorizationGrantType.AUTHORIZATION_CODE is supported. The issuer \"" + issuer + "\" returned a configuration of " + grantTypes ) ; } List < String > scopes = getScopes ( metadata ) ; Map < String , Object > configurationMetadata = new LinkedHashMap <> ( metadata . toJSONObject ( ) ) ; return ClientRegistration . withRegistrationId ( name ) . userNameAttributeName ( IdTokenClaimNames . SUB ) . scope ( scopes ) . authorizationGrantType ( AuthorizationGrantType . AUTHORIZATION_CODE ) . clientAuthenticationMethod ( method ) . redirectUriTemplate ( "{baseUrl}/{action}/oauth2/code/{registrationId}" ) . authorizationUri ( metadata . getAuthorizationEndpointURI ( ) . toASCIIString ( ) ) . jwkSetUri ( metadata . getJWKSetURI ( ) . toASCIIString ( ) ) . providerConfigurationMetadata ( configurationMetadata ) . userInfoUri ( metadata . getUserInfoEndpointURI ( ) . toASCIIString ( ) ) . tokenUri ( metadata . getTokenEndpointURI ( ) . toASCIIString ( ) ) . clientName ( issuer ) ; }
Creates a {@link ClientRegistration.Builder}  using the provided
<a href="https://openid.net/specs/openid-connect-core-1_0.html#IssuerIdentifier">Issuer</a> by making an
<a href="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest">OpenID Provider
Configuration Request</a> and using the values in the
<a href="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse">OpenID
Provider Configuration Response</a> to initialize the {@link ClientRegistration.Builder}.

<p>
For example, if the issuer provided is "https://example.com", then an "OpenID Provider Configuration Request" will
be made to "https://example.com/.well-known/openid-configuration". The result is expected to be an "OpenID
Provider Configuration Response".
</p>

<p>
Example usage:
</p>
<pre>
ClientRegistration registration = ClientRegistrations.fromOidcIssuerLocation("https://example.com")
.clientId("client-id")
.clientSecret("client-secret")
.build();
</pre>
@param issuer the <a href="https://openid.net/specs/openid-connect-core-1_0.html#IssuerIdentifier">Issuer</a>
@return a {@link ClientRegistration.Builder} that was initialized by the OpenID Provider Configuration.
Creates a { @link ClientRegistration . Builder } using the provided <a href = https : // openid . net / specs / openid - connect - core - 1_0 . html#IssuerIdentifier > Issuer< / a > by making an <a href = https : // openid . net / specs / openid - connect - discovery - 1_0 . html#ProviderConfigurationRequest > OpenID Provider Configuration Request< / a > and using the values in the <a href = https : // openid . net / specs / openid - connect - discovery - 1_0 . html#ProviderConfigurationResponse > OpenID Provider Configuration Response< / a > to initialize the { @link ClientRegistration . Builder } .