【问题标题】:Unable to get Access Token in Jmeter无法在 Jmeter 中获取访问令牌
【发布时间】:2020-06-08 15:11:36
【问题描述】:

我正在尝试在 Jmeter 中获取访问令牌,它与邮递员一起工作正常,但我最终在 Jmeter 中响应错误提示

{
   "error":"invalid_grant",
   "error_description":"The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
   "status_code":400
}

邮递员身体

邮递员中的标题

当我发布此请求时,我得到了访问令牌作为 json 响应

我在 Jmeter 中的设置如下:

HTTP 请求

HTTP 标头

当我在 jmeter 中运行测试时得到以下响应

{
   "error":"invalid_grant",
   "error_description":"The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
   "status_code":400
}

【问题讨论】:

  • 请提供jmeter日志。要获取或提取访问令牌,您应该使用 Json 提取器或 xpath 提取器。

标签: rest api oauth jmeter performance-testing


【解决方案1】:

如果您发送相同的请求,您应该得到相同的响应,因此很可能请求在某处有所不同。

您需要使用 View Results Tree 监听器比较 raw request body from Postman 和 JMeter 中的相同

一个明显的区别是 JMeter 中缺少 Accept 标头。

可能是${_code}${base64HeaderValue} 等变量没有各自的值,您可能需要使用Debug Sampler 检查它们

最后但并非最不重要的一点是,如果您的请求在 Postman 中有效,您可以使用 JMeter 的 HTTP(S) Test Script Recorder 记录它,只需 configure Postman to use JMeter as the proxy

下次您在 Posman 中运行请求时,JMeter 将捕获它并将相关的 HTTP 请求采样器(使用 HTTP 标头管理器)存储在 Recording Controller 下

【讨论】:

    猜你喜欢
    • 2022-01-01
    • 2021-09-16
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-21
    相关资源
    最近更新 更多