[1]
How can I get the session parameters of the current JIRA web session. I need username and password for authentication purposes (REST).
[2]
I want to switch from basic authentication to oauth. Can somebody give me an code example how to do that! Thank you very much!
This is my current code:
String auth = new String(Base64.encode("username:password")); Client client = Client.create(); WebResource webResource = client.resource("http://ubuntu:2990/jira/rest/api/2/search?jql=project=DEMO"); ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").get(ClientResponse.class); int statusCode = response.getStatus(); if (statusCode == 401) { throw new AuthenticationException("Invalid Username or Password"); }
Community moderators have prevented the ability to post new answers.
Hi,
here the long way to the solution. A full answer with full source code would be to complex for Atlassian Answer. So you must read the documentation yourself and understand the complete process (e.g. three parts of OAuth dance, Consumer, Service Provider...):
1. Setup your environment ( Step 1 beneath https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication )
2. Study the java code in https://developer.atlassian.com/download/attachments/6291692/rest-oauth-client-1.0-sources.jar?api=v2 (extract this jar, it contains 3 files)
I hope this helps!
Mathias, could I trouble you for some code snippets from your solution? I'm probably looking at having to do something similar.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mathias, This is answers.atlassian.com, it is not helpful to just post that you resolved it without actually providing a relevant solution. I am now the second person that has come across this answer and would also like code snippets or something to indicate how you were able to resolve your issue. Please let us know. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am now the third person looking for the code Bro, @Mathias Liefke [primefield software] , could you please show up some code, so that it will help us to solve our problems. Thanks in advance !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this answer ok for you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mathias,
I was testing this out, but end up finding a public page that should help you through this. :) Please check out the JIRA REST API Example - OAuth authentication. Just remember to create the Application Link in JIRA and to configure the "OAuth Dance" in your code.
I hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you give me an example how I can implement this in java (plugin for JIRA)? Thank you!
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.