Spring Boot 3 OAuth2 Client for non reactive project

Karanbir Singh
2 min readAug 19, 2023

If not a medium member, try using the link here to view it for free.

Spring Boot 2.x.x sometime back had introduced a WebClient based OAuth2 Client & when we say WebClient that is Reactive & that does not works with a servlets based project out of the box in a go. You will get some errors for sure.

Reason for the error is the underneath framework to call token endpoint to resolve the access token should not be reactive.

So this blog post is dedicated to the very specific problem statement & the solution around the same. The blog post here majorly is code only. With a representational image for explanation.

Flow Diagram

Animation for the flow

Code

The code makes use of Spring Boot 3 + JDK17

There are mainly 3 components:-

1. The Main Server that acts as an OAuth2 client. https://github.com/krnbr/spring-boot-oauth2-servlets
2. Auth Server for generating/ managing the OAuth2 access tokens. https://github.com/krnbr/spring-oauth2-server
3. Resource Server that is protected by the OAuth2 access token

--

--

Karanbir Singh

API developer + Web Application developer + Devops Engineer = Full Stack Developer