无法在Jmeter中获取访问令牌

时间:2020-02-24 23:06:13

标签: rest api oauth jmeter performance-testing

我正在尝试在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
}

邮递员的身体 enter image description here

邮递员头 enter image description here

发布此请求时,我将访问令牌作为json响应

我在Jmeter中的设置如下:

HTTP请求 enter image description here

HTTP标头 enter image description here

在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
}

1 个答案:

答案 0 :(得分:0)

鉴于您发送相同的请求,您应该获得相同的响应,因此,很可能这些请求在某种程度上有所不同。

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

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

可能是${_code}${base64HeaderValue}之类的变量没有各自的值的情况,您可能需要使用Debug Sampler进行检查

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

enter image description here

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

相关问题