如何让 Postman 自动复制JWT 登录后的 Token 到其他API请求?

Save the JWT as a variable

创建一个 global variable.

先在Postman你的登录API中,打开 test Tab。

输入下面的代码

const response = pm.response.json();
pm.globals.set("jwt_token", response.access_token);

使用 Global variable

在 REST API 的 Authentication tab 中,使用变量。

{{jwt_token}}

在这里插入图片描述

使用

先 Send 一次 Login API,然后再访问其他 REST API 即可。

参考资料

using-jwt-to-authenticate-and-authorize-requests-in-postman

发布了63 篇原创文章 · 获赞 25 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/yangbo_hr/article/details/105455370