postman - postman 中的授权不记名 token

标签 postman newman postman-collection-runner

我正在尝试使用 Newman 自动化 postman 测试.授权有问题。授权 bearer token 发生变化并且是动态的。有谁知道如何自动执行此操作?

最佳答案

Postman 有变量这个很好的特性。 你可以在这里阅读更多关于它们的信息: https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables

您可以将不记名 token 存储在一个变量中,并根据您的要求定期更新它。

Using global variable

您可以根据需要在预请求脚本/测试脚本中修改此 token 。

例如:

let token = pm.globals.get('dynamic_token');
token = 'newModifiedToken90332'; // Perform some operations here.. 

pm.globals.set('dynamic_token', token);

Pre-request script

您可以将集合和全局变量导出到 Newman 中并使用它们。

来自 Newman documentation您可以执行以下操作:

$ newman run mycollection.json -e dev_environment.json

-e 用于使用环境变量,您可以在其中存储不记名 token 回想一下,您也可以导出集合和环境变量。

关于postman - postman 中的授权不记名 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49799207/

相关文章:

不使用 Postman Cloud sync 的 Postman 商业用途 >3 人团队

postman - 如何使用 Postman Collection Runner 运行单个请求?

postman - 是否有一种编程方式来导出 Postman Collections?

java - 了解 Postman 请求是如何在 java 中构造和复制的

postman - 如何将响应正文从 Postman Collection Runner Results 导出/下载到外部文件中?

ssl - Newman 加载 pfx 证书,但不用于连接到端点

decimal - 如何获取 Postman 中 json 响应中提供的所有十进制数字?

asp.net-core - 如何使用 Postman 调用 Identity Server 4 进行登录

javascript - 在 HTTP 触发器 azure 中等待 Newman 响应

postman - 在 postman 收集运行中禁用请求