如何使用Twitter的空手道设置oauth 1.0身份验证?

问题描述 投票:1回答:1

我正在使用空手道来实现自动化,并且必须使用oauth 1.0身份验证,该身份验证包含4个字段,分别是令牌,令牌密钥,使用者密钥和使用者密钥。空手道我做不到。您能帮我解决这个问题吗?

我曾尝试使用configure标头选项来实现某些功能,但未成功。我没有空手道的经验,我无法尝试其他任何方法。

这就是我放心使用的方式。我想用空手道实现相同的逻辑。下面是放心的代码;

'''响应响应=给定().auth()。oauth(consumerKey,ConsumerSecret,token,tokenSceret)。queryParam(“ screen_name”,“ realDonaldTrump”)。queryParam(“ count”,1)。when()。get(“ / user_timeline.json”)。then()。extract()。response();'''

oauth twitter-oauth karate
1个回答
0
投票

请参考演示:https://github.com/intuit/karate/tree/master/karate-demo

然后看OAuth1 example

它要求您执行Java Interop:https://github.com/intuit/karate#calling-java

因此,除非您准备编写one Java class并从Karate中使用它,否则您可以选择寻找其他框架。

并且如果需要,您还需要引用Twitter API:https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature

这不是空手道中内置的,因为它可以变得非常特殊。如果需要,请尽一切可能帮助Java的人。

* def Signer = Java.type('com.myco.Signer')    
* def params =
"""
{ 
  'userId': '399645532', 
  'os':'android', 
  'client_key': '3c2cd3f3',
  'token': '141a649988c946ae9b5356049c316c5d-838424771',
  'token_client_salt': 'd340a54c43d5642e21289f7ede858995'
}
"""
* Signer.sign('382700b563f4', params)
* path 'echo'
* form fields params
* method post
* status 200
© www.soinside.com 2019 - 2024. All rights reserved.