Token based authentication with Springboot application and Swagger-UI where user logs in with username and password (basic authentication)

Solution 1:

I figured out the solution with custom solution. More details below.

  1. I had followed all the steps given at this thread - https://stackoverflow.com/a/46715492/5390096
  2. The issue was with the swagger-ui version 2.9.2 which does not pass client_id and client_password when the authentication form is submitted. I was keep getting bad request and after UI debugging and few more google searches, I found the issue.
  3. I created a customer controller which gets called on this form submission and then I internally make a call to my token uri by passing the client_id and client_secret
  4. If I bump the version to 3.0.0 then I get other conflict issues, didn't spend time fixing that.
  5. Other option I had was to migrate to openapi swagger-ui (new version of swagger-ui) but to save time and code refactoring, I chose to create a custom controller.