I am trying to make a request to Tweeter with OAuth1 authentication method in Python I manage to do it with requests library but on Java I use Rest assured. Following code does not work, its return Unauthorized :
Response response = given()
.headers(headerEmpty())
.auth()
.oauth(twitterSettings.getApiKey(), twitterSettings.getApiKeySecret(),
twitterSettings.getAccessToken(), twitterSettings.getAccessTokenSecret())
.spec(baseUrl)
.get("users/me")
.then()
.extract().response();
I look online and I found I need to use probably Scribejava library but not sure how to combine with Rest Assured I am not lazy but some help.
EDIT:
I add the dependencies for Scribe and still does not work.
public static Headers headerEmpty() {
Header contentType = new Header("Content-Type", "application/json");
Header acceptType = new Header("Accept", "*/*");
List<Header> headerList = new ArrayList<>();
headerList.add(contentType);
headerList.add(acceptType);
return new Headers(headerList);
}
2
Answers
I think the problem is because of the missing header.
Try adding this header to the request above:
In order to see exactly the headers you are passing you can change your code like this:
I came up on similar problem with Rest assured and OAuth1.
I resolved problem in this way:
I had a problem to set PLAINTEXT as signature_method.