I'd been using the Postman in-tab extension to tests calls to call JHipster resource API's and found that it worked great (JHipster setup to use OAuth2). I authenticated using the JHipster login page, then opened up a new tab with the Postman extension.
I just switched my JHipster application to use JWT and this method of using Postman no longer works, I get permission denied when calling the API. Moreover, the in-tab extension for Postman is being deprecated in favor of the stand-alone app.
Question: Is there any documentation on setting up Postman for authenticating against JHipster/JWT?
It is possible to use Postman with a JWT JHipster app.
- First, authenticate with the JHipster app
- Inspect any API request for the
Authorization
header. The JWT token is the value to the right of "Bearer ". You can also find this token in the browser's localStorage under the key jhi-authenticationToken
.
Edit the headers in Postman and add the Authorization
header. The value should look like the following:
Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJydRkZWxsIiwiYXV0aCI6IlJPTEVfQURNSU4sUk9MRV9U0VSIiwiZXhwIjoxNDgzOTg1MDkzfQ.1A13sBvr3KDWxJQpKDKOS33KAVjWIb3mS_qfxLBOCq_LbMwNHnysAai0SNXXgudMOulAnXYN9_Mzlcv1_zctA
The easiest way for me is
log into your Jhipster Web app with the admin credential
Select Administration > API
- Then choose any of existing API and click 'Try it out' button
It will list a curl
action with the token, now you can grab the token and use it in Postman