Different response result between swagger REST documentation and in its implementation

Hi All…

Recently I try to use REST and try to POST /oauth/token

Well it is worked , but I have a problem when I try to put wrong user/password in order to raise ‘error response’.

According to Swagger UI , when something wrong happen with user/password , the response from server should
“401 Unauthorized”, but instead I receive “Unexpected response status: 400”

What does it mean ?

Hi,
According to the Oauth2 spec, when there is invalid data in the request body, the response with code 400 (Bad request) is returned. The response with code 401 (Unauthorized) is returned when basic authentication for the endpoint failed. We’ll update the swagger documentation

Hi,

Yes I actually expecting response code is 401 because I input wrong password to api below http://"+server_host+":8080/app/rest/v2/oauth/token

But instead of receiving 401 , I receiving code 400 ,

Please see my attachment for java code that I use, maybe you can review the code ?

Thankssample_code.java (3.9 KB)

As I already mentioned, according to the specification the correct code here is 400. See the OAuth2 specification

Oh I see,
I have misunderstood your previous explanation then

Thanks @gorbunkov

:slight_smile: