JHIPster authentication using Postman and JWT

I used the Postman in-tab extension to test calls to call the JHipster resource API and found that it works fine (setting up JHipster to use OAuth2). I authenticated using the JHipster login page, and then opened a new tab with the Postman extension.

I just switched the JHipster application to using JWT, and this method of using Postman no longer works, I get permission denied when calling the API. In addition, the insertion extension for Postman is deprecated in favor of a standalone application.

Question: Is there any documentation on setting up Postman for authentication with JHipster / JWT?

+4
source share
2 answers

You can use Postman with the JWT JHipster app.

  • Authenticate with JHipster app first
  • Inspect any API request for a header Authorization. The JWT mark is the value to the right of Bearer. You can also find this token in the localStorage browser under the key jhi-authenticationToken.
  • Change the titles in Postman and add a title Authorization. The value should look like this:

    Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJydRkZWxsIiwiYXV0aCI6IlJPTEVfQURNSU4sUk9MRV9U0VSIiwiZXhwIjoxNDgzOTg1MDkzfQ.1A13sBvr3KDWxJQpKDKOS33KAVjWIb3mS_qfxLBOCq_LbMwNHnysAai0SNXXgudMOulAnXYN9_Mzlcv1_zctA
    
+10
source
  • Send a POST request to /api/authenticatethe following bodies: {"password":"admin","username":"admin"}. You will receive the following answer:{"id_token":"aabbccddeeff"}
  • Make your subsequent requests using the value of the token received in the previous call and enter Authorization: Bearer aabbccddeeff
  • You can check the authentication status by making a GET request to the endpoint /api/authenticate
+8

Source: https://habr.com/ru/post/1663548/


All Articles