使用Postman和JWT的JHipster身份验证

问题描述:

我一直在使用Postman选项卡内扩展来测试调用JHipster资源API的调用,并发现它工作得很好(JHipster设置为使用OAuth2).我使用JHipster登录页面进行了身份验证,然后打开了一个带有Postman扩展名的新标签.

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.

我刚刚将我的JHipster应用程序切换为使用JWT,并且这种使用Postman的方法不再起作用,调用API时我被拒绝了权限.此外,不赞成使用Postman的选项卡内扩展程序,而希望使用独立应用程序.

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.

问题:是否存在任何有关设置Postman来针对JHipster/JWT进行身份验证的文档?

Question: Is there any documentation on setting up Postman for authenticating against JHipster/JWT?

  1. 使用以下正文向/api/authenticate发出POST请求: {"password":"admin","username":"admin"}.您将收到以下响应:{"id_token":"aabbccddeeff"}
  2. 使用上一次调用中收到的令牌的值发出后续请求,并将其放入Authorization: Bearer aabbccddeeff
  3. 您可以检查身份验证的状态,向/api/authenticate端点
  4. 发出GET请求
  1. Make a POST request to /api/authenticate with the following body: {"password":"admin","username":"admin"}. You will receive the following response: {"id_token":"aabbccddeeff"}
  2. Make your subsequent requests using the value of the token received in the previous call and put in into an Authorization: Bearer aabbccddeeff
  3. You can check the status of the authentication, making a GET request to /api/authenticate endpoint