我有一个GET API请求,需要通过JMeter传递,但它需要鹰身份验证。我还有Hawk Auth ID,Hawk Auth键,算法值。
在postman中,它可以正常工作,但是当将postman脚本转换为JMeter脚本并执行时,它会给出一个类似于“未经授权”的错误消息&响应代码- 401。
因此,我需要知道在JMeter中Hawk认证的配置过程。
有人能帮我一下吗?
发布于 2022-07-05 15:47:23
尝试Hawk Java API实现,示例代码可以在
在Building Your Own -> Clients文档一章中提供了包含说明的示例代码,以防万一我将在这里复制代码片段:
import com.wealdtech.hawk.HawkClient
import com.wealdtech.hawk.HawkCredentials
import com.wealdtech.hawk.HawkCredentials.Algorithm
//If you want your clients to authenticate using Hawk then you will need to start with a set of Hawk credentials:
HawkCredentials hawkCredentials = new HawkCredentials.Builder()
.keyId("dh37fgj492je")
.key("werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn")
.algorithm(Algorithm.SHA256)
.build();
//Once these have been configuration you can create a Hawk client:
HawkClient hawkClient = new HawkClient.Builder().credentials(hawkCredentials).build();
//And then for each request that you wish to send you need to generate an authorization header:
String authorizationHeader = hawkClient.generateAuthorizationHeader(uri, method, body, ext);
//This string needs to be added to the outgoing HTTP request as the content of the "Authorization" header.
//and JMeter specifics:
vars.put('authorizationHeader', authorizationHeader)您需要将这些代码放入JSR223 PreProcessor中
https://stackoverflow.com/questions/72870748
复制相似问题