|
@@ -29,15 +29,15 @@ Spring Security builds on this support to provide additional benefits:
|
|
== WebClient OAuth2 Setup
|
|
== WebClient OAuth2 Setup
|
|
|
|
|
|
The first step is ensuring to setup the `WebClient` correctly.
|
|
The first step is ensuring to setup the `WebClient` correctly.
|
|
-An example of setting up `WebClient` in a fully reactive environment can be found below:
|
|
|
|
|
|
+An example of setting up `WebClient` in a servlet environment can be found below:
|
|
|
|
|
|
[source,java]
|
|
[source,java]
|
|
----
|
|
----
|
|
@Bean
|
|
@Bean
|
|
-WebClient webClient(ReactiveClientRegistrationRepository clientRegistrations,
|
|
|
|
- ServerOAuth2AuthorizedClientRepository authorizedClients) {
|
|
|
|
- ServerOAuth2AuthorizedClientExchangeFilterFunction oauth =
|
|
|
|
- new ServerOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients);
|
|
|
|
|
|
+WebClient webClient(ClientRegistrationRepository clientRegistrations,
|
|
|
|
+ OAuth2AuthorizedClientRepository authorizedClients) {
|
|
|
|
+ ServletOAuth2AuthorizedClientExchangeFilterFunction oauth =
|
|
|
|
+ new ServletOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients);
|
|
// (optional) explicitly opt into using the oauth2Login to provide an access token implicitly
|
|
// (optional) explicitly opt into using the oauth2Login to provide an access token implicitly
|
|
// oauth.setDefaultOAuth2AuthorizedClient(true);
|
|
// oauth.setDefaultOAuth2AuthorizedClient(true);
|
|
// (optional) set a default ClientRegistration.registrationId
|
|
// (optional) set a default ClientRegistration.registrationId
|
|
@@ -67,7 +67,7 @@ Mono<String> body = this.webClient
|
|
[[servlet-webclient-explicit]]
|
|
[[servlet-webclient-explicit]]
|
|
== Explicit OAuth2AuthorizedClient
|
|
== Explicit OAuth2AuthorizedClient
|
|
|
|
|
|
-The `OAuth2AuthorizedClient` can be explicitly provided by setting it on the requests attributes.
|
|
|
|
|
|
+The `OAuth2AuthorizedClient` can be explicitly provided by setting it on the request attributes.
|
|
In the example below we resolve the `OAuth2AuthorizedClient` using Spring WebFlux or Spring MVC argument resolver support.
|
|
In the example below we resolve the `OAuth2AuthorizedClient` using Spring WebFlux or Spring MVC argument resolver support.
|
|
However, it does not matter how the `OAuth2AuthorizedClient` is resolved.
|
|
However, it does not matter how the `OAuth2AuthorizedClient` is resolved.
|
|
|
|
|