Hi!
I'm developing a JIRA plugin. I want to access data (issues, structures etc...) from JIRA from Java. I have tried to use Jersey Rest Client because it looks like JRJC does not support all the request I want to do (like request to the Structure Rest API etc..).
At the moment I have this, but I do not want to hardcode a username and password in java. I want to use the currently logged in user to access the data. If I remove the basic auth (second line) "client.addFilter(new HTTPBasicAuthFilter("admin", "admin"));" I am denied access (error 401).
Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("admin", "admin")); WebResource webResource = client.resource(baseurl + url); ClientResponse response = webResource.accept("application/json").get(ClientResponse.class); if (response.getStatus() != 200) { return "Error: " + response.getStatus(); } else{ return response.getEntity(String.class); }
Thanks!
Community moderators have prevented the ability to post new answers.
If using the HTTPBasicAuthFilter, you will have to send the user / password.
What you can do instead is to create an OAuth token and use it to login.
For more details, check the documentation with examples at https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication
Hi, Pedro, I have almost the same question. The plugin that Maria writes works in the same process as Jira itself. So what's the need to authenticate rest client? The jira process is already authenticated. Is there any way to call Jira REST API from inside Jira without the need to authenticate again? Can we access some core http client info and use it to call REST?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.