Get jwt token using http post method and then pass it in each api method on swagger page

Viewed 229

I want to do the following authentication in swagger page:

  1. Pass the username and password to a swagger authentication window.
  2. Add the username and password to a post request body to an authentication endpoint (like http:localhost:1111/login).
  3. Get the response with a jwt token.
  4. Add the jwt token into the body of all http methods in swagger page (like: "Authorization: Bearer <jwt_token>")

I didn't find anything about creating your own SecuritySchema or SecurityContext, so maybe it is possible to do with library classes and methods.

I can add jwt token into the body of all http methods as mentioned here: Spring Boot & Swagger UI. Set JWT token And add a window with username and password and send post method to specific endpoint as mentioned here: How to configure oAuth2 with password flow with Swagger ui in spring boot rest application. But I don't know how to make the authentication I mentioned earlier.

Any help will be highly appreciated.

I use: sprint boot 2.2.5, springfox 2.9.2

EDIT: I get jwt token after authentication like here: How to configure oAuth2 with password flow with Swagger ui in spring boot rest application, but I don't how to pass that value to http methods in swagger.

P.S. I don't want to use Spring Security.

0 Answers
Related