Request as other user 2-Legged OAuth

oauth2

#1

Hi,

I’m trying to send a post request to Jira using 2-Legged OAuth, but I don’t know where to put the username to be impersonated

private JSONObject handlePostRequest(PropertiesCall arguments) {
Map<String, String> properties = propertiesClient.getPropertiesOrDefaults();
String url = properties.get(JIRA_HOME) + arguments.getApi();
try {
OAuthParameters parameters = this.getOAuthParameters();
HttpResponse response = sendResponsePostFromUrl(parameters, new GenericUrl(url), arguments);
return parseResponse(response);
} catch (HttpResponseException e) {
log.error(e.getMessage());
return new JSONObject(e.getContent());
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}

private static HttpResponse sendResponsePostFromUrl(OAuthParameters parameters, GenericUrl jiraUrl,
PropertiesCall arguments) throws IOException {
HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory(parameters);
HttpRequest request = requestFactory.buildPostRequest(jiraUrl,
ByteArrayContent.fromString(“application/json”, arguments.getParametros()));
return request.execute();
}


#2

I need help with this, please


#3

Any help with this, please???. I’ve not found examples