-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: WebClient OAuth2 Setup for Reactive Applications might be wrong #8444
Comments
I experience the same thing. When doing av webClient.get() outside Servlet context i get "servletRequest cannot be null". If I do the whole call inside a @controller or @RestController it works fine. |
@fabian-froehlich @Avec112 The issue here is that the OAuth 2.0 Client Reactive documentation is out-of-date and missing quite a bit of content compared to the Servlet sections. Take a look at the OAuth2AuthorizedClientManager / OAuth2AuthorizedClientProvider (Servlet) docs:
Since 5.2, it's recommended to use the
This makes sense, however, I would recommend using the We have #8174 logged to get the Reactive docs in sync with the Servlet docs. I'll close this issue as answered. If something is still not clear let me know and we'll address it. |
Hi @jgrandja, If I am understanding you correct, then your recommendet way is what I wrote in my initial post as a running example, right? And it seems that I am outside of a Could you give me an insight, if any possible error here, results in my finding, that Mon.retryWhen(..) does not handle a correct token refresh, when retrys are triggered? Kind regards, |
There are plenty of examples in the reference documentation so please take a look there. Again, the reactive docs are out of date so check out the Servlet docs (the only difference between Servlet and Reactive are the class names).
|
Hi @jgrandja and sorry for your trouble.
|
Given that you're seeing NOTE: Change the |
Added WebClientConfiguration class like described above but when I'm trying to run app I see in log: How could it be solved? Here code of my class:
SOLVED.
and change AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager bean:
|
Hello Eugene, I configured exactly the same beans as you (like AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager) but when I execute my code is always an instance of DefaultReactiveOAuth2AuthorizedClientManager that is being executed. |
@andrecampanini, just a note that since the last comment on this thread, we have updated the reactive section of the documentation. See the section on ReactiveOAuth2AuthorizedClientManager. It may be worth reading through the entire chapter in context. If you have anything that looks like a bug, feel free to file a new issue with a minimal sample that reproduces the issue. |
In the reference doc there is an example for a WebClient with OAuth2 Setup for Reactive Applications: https://docs.spring.io/spring-security/site/docs/current/reference/html5/#webclient-setup
But in my szenario it leads to an exception:
However, switching the
ServerOAuth2AuthorizedClientRepository
to aReactiveOAuth2AuthorizedClientService
makes the code run.Is that an issue or am I handling something wrong?
I am not sure if there is a correlation but, the working code example does not retrieve a new token, when
Mono.retryWhen(...)
is used.The text was updated successfully, but these errors were encountered: