使用 Jmeter xpath 提取器获取 oauth 令牌并在其他 Http 请求的路径中使用它 [英] Getting oauth token using Jmeter xpath extractor and using it in path of other Http Request

查看:21
本文介绍了使用 Jmeter xpath 提取器获取 oauth 令牌并在其他 Http 请求的路径中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想提取访问令牌的值,正则表达式应该是什么,以便我可以在其他 Http 请求的路径中使用它,例如 access_token=93ee29b4-74dc-​​4uu7-8e10-6eac6845511b 来自下面的 http 响应.

<代码>{"access_token":"93ee2tum-1234-56789-8e10-6eac684551tum","token_type":"承载","expires_in":3600,范围":测试"}

我已经给出了正则表达式

<块引用>

"access_token":"([^"]+)"

还有我在哪里可以检查我得到的正则表达式的值

解决方案

您可以使用

您也可以使用

What should be the Regular expression if I want to extract the value for access token, So that i can use it in Path of other Http request ie like access_token=93ee29b4-74dc-4uu7-8e10-6eac6845511b from below http response.

{
   "access_token":"93ee2tum-1234-56789-8e10-6eac684551tum",
   "token_type":"Bearer",
   "expires_in":3600,
   "scope":"test"
}

I have given regular expression as

"access_token":"([^"]+)"

And also where can i check the value of regular expression I am getting

解决方案

You can test your Regular Expressions using View Results Tree listener in RegExp Tester mode like:

Also you can use Debug Sampler to see the associated JMeter Variables. See How to Debug your Apache JMeter Script article for details.


Starting from JMeter 3.0 it's more handy to use JSON Path PostProcessor, in that case the relevant JSON Path Expression would be as simple as:

$.access_token 

这篇关于使用 Jmeter xpath 提取器获取 oauth 令牌并在其他 Http 请求的路径中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆