Skip to content

Commit 15c2b15

Browse files
committed
Update Client Authentication examples
Closes gh-16925 987d9c9788ba0343f543083c87613fb5
1 parent 0e70482 commit 15c2b15

File tree

1 file changed

+18
-39
lines changed

1 file changed

+18
-39
lines changed

docs/modules/ROOT/pages/servlet/oauth2/client/client-authentication.adoc

+18-39
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spring:
2727
...
2828
----
2929

30-
The following example shows how to configure `DefaultAuthorizationCodeTokenResponseClient` to disable URL encoding of the client credentials:
30+
The following example shows how to configure `RestClientAuthorizationCodeTokenResponseClient` to disable URL encoding of the client credentials:
3131

3232
[tabs]
3333
======
@@ -39,13 +39,9 @@ DefaultOAuth2TokenRequestHeadersConverter<OAuth2AuthorizationCodeGrantRequest> h
3939
new DefaultOAuth2TokenRequestHeadersConverter<>();
4040
headersConverter.setEncodeClientCredentials(false);
4141
42-
OAuth2AuthorizationCodeGrantRequestEntityConverter requestEntityConverter =
43-
new OAuth2AuthorizationCodeGrantRequestEntityConverter();
44-
requestEntityConverter.setHeadersConverter(headersConverter);
45-
46-
DefaultAuthorizationCodeTokenResponseClient tokenResponseClient =
47-
new DefaultAuthorizationCodeTokenResponseClient();
48-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter);
42+
RestClientAuthorizationCodeTokenResponseClient tokenResponseClient =
43+
new RestClientAuthorizationCodeTokenResponseClient();
44+
tokenResponseClient.setHeadersConverter(headersConverter);
4945
----
5046
5147
Kotlin::
@@ -55,11 +51,8 @@ Kotlin::
5551
val headersConverter = DefaultOAuth2TokenRequestHeadersConverter<OAuth2AuthorizationCodeGrantRequest>()
5652
headersConverter.setEncodeClientCredentials(false)
5753
58-
val requestEntityConverter = OAuth2AuthorizationCodeGrantRequestEntityConverter()
59-
requestEntityConverter.setHeadersConverter(headersConverter)
60-
61-
val tokenResponseClient = DefaultAuthorizationCodeTokenResponseClient()
62-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter)
54+
val tokenResponseClient = RestClientAuthorizationCodeTokenResponseClient()
55+
tokenResponseClient.setHeadersConverter(headersConverter)
6356
----
6457
======
6558

@@ -119,7 +112,7 @@ spring:
119112
...
120113
----
121114

122-
The following example shows how to configure `DefaultAuthorizationCodeTokenResponseClient`:
115+
The following example shows how to configure `RestClientAuthorizationCodeTokenResponseClient`:
123116

124117
[tabs]
125118
======
@@ -140,14 +133,10 @@ Function<ClientRegistration, JWK> jwkResolver = (clientRegistration) -> {
140133
return null;
141134
};
142135
143-
OAuth2AuthorizationCodeGrantRequestEntityConverter requestEntityConverter =
144-
new OAuth2AuthorizationCodeGrantRequestEntityConverter();
145-
requestEntityConverter.addParametersConverter(
136+
RestClientAuthorizationCodeTokenResponseClient tokenResponseClient =
137+
new RestClientAuthorizationCodeTokenResponseClient();
138+
tokenResponseClient.addParametersConverter(
146139
new NimbusJwtClientAuthenticationParametersConverter<>(jwkResolver));
147-
148-
DefaultAuthorizationCodeTokenResponseClient tokenResponseClient =
149-
new DefaultAuthorizationCodeTokenResponseClient();
150-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter);
151140
----
152141
153142
Kotlin::
@@ -168,13 +157,10 @@ val jwkResolver: Function<ClientRegistration, JWK> =
168157
null
169158
}
170159
171-
val requestEntityConverter = OAuth2AuthorizationCodeGrantRequestEntityConverter()
172-
requestEntityConverter.addParametersConverter(
160+
val tokenResponseClient = RestClientAuthorizationCodeTokenResponseClient()
161+
tokenResponseClient.addParametersConverter(
173162
NimbusJwtClientAuthenticationParametersConverter(jwkResolver)
174163
)
175-
176-
val tokenResponseClient = DefaultAuthorizationCodeTokenResponseClient()
177-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter)
178164
----
179165
======
180166

@@ -198,7 +184,7 @@ spring:
198184
...
199185
----
200186

201-
The following example shows how to configure `DefaultClientCredentialsTokenResponseClient`:
187+
The following example shows how to configure `RestClientClientCredentialsTokenResponseClient`:
202188

203189
[tabs]
204190
======
@@ -218,14 +204,10 @@ Function<ClientRegistration, JWK> jwkResolver = (clientRegistration) -> {
218204
return null;
219205
};
220206
221-
OAuth2ClientCredentialsGrantRequestEntityConverter requestEntityConverter =
222-
new OAuth2ClientCredentialsGrantRequestEntityConverter();
223-
requestEntityConverter.addParametersConverter(
207+
RestClientClientCredentialsTokenResponseClient tokenResponseClient =
208+
new RestClientClientCredentialsTokenResponseClient();
209+
tokenResponseClient.addParametersConverter(
224210
new NimbusJwtClientAuthenticationParametersConverter<>(jwkResolver));
225-
226-
DefaultClientCredentialsTokenResponseClient tokenResponseClient =
227-
new DefaultClientCredentialsTokenResponseClient();
228-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter);
229211
----
230212
231213
Kotlin::
@@ -245,13 +227,10 @@ val jwkResolver = Function<ClientRegistration, JWK?> { clientRegistration: Clien
245227
null
246228
}
247229
248-
val requestEntityConverter = OAuth2ClientCredentialsGrantRequestEntityConverter()
249-
requestEntityConverter.addParametersConverter(
230+
val tokenResponseClient = RestClientClientCredentialsTokenResponseClient()
231+
tokenResponseClient.addParametersConverter(
250232
NimbusJwtClientAuthenticationParametersConverter(jwkResolver)
251233
)
252-
253-
val tokenResponseClient = DefaultClientCredentialsTokenResponseClient()
254-
tokenResponseClient.setRequestEntityConverter(requestEntityConverter)
255234
----
256235
======
257236

0 commit comments

Comments
 (0)