Relative Content

Tag Archive for spring-boothttp-status-code-401

How to send custom status code in Spring Boot /oauth/token API (spring version 2.5.2)

In spring boot projact, I want to handle oauth/token API. If credentials are correct, it successfully return status: 200 and other details (access token, refresh token, etc).
I created Java class Oauth2UserServiceImpl by implementing UserDetailsService. Then overrided loadUserByUsername method. Inside that, before checking the credential validity, I need to check whether this user’s status is ‘Active’ and password expiered. The following code shows the way I’m checking it.