Jira OAuth integration

rest-api

#1

Could anyone can help to provide JIRA API with OAuth authentication from java application…


#2

Hello @janardhanreddy.bored,

If you’re interested with Jira server, you might want to check out this OAuth documentation. There is step by step directions on what and how to do it.

Hope this helps.
Ian


#3

Hi Ian,

Thanks for your reply, I have gone through the link you shared and it says clone the sample code from https://bitbucket.org/atlassian_tutorial/atlassian-oauth-examples but it’s not available.

For basic auth we use like below to connect to jira
Client client = null;
Response response = null;
try {
client = ClientBuilder.newClient();
WebTarget webTarget = client.target(url);
response = webTarget.request().header(HttpHeaders.AUTHORIZATION, Base64.getEncoder().encode(username.concat(":").concat(password).getBytes())).accept(MediaType.APPLICATION_JSON).get();
} catch (Exception e) {
e.printStackTrace();
throw new JiraException();
}
return response;

How could we configure for OAuth instead of basic authentication.?


#4

Hi, I was able to clone it just now, it uses mercurial. You can also browse the repository and drill into the projects; I believe you’re more interested with the contents of java folder.

Cheers,
Ian


#5

I’m cloning from GIT repository and getting below error…


#6

The error was caused by using Git in checking out the Mercurial repository. In order to clone this repo, you will be needing to install Mercurial.


#7

Hi Ian,

I’m getting below error could you please help what might went wrong…

Creating default properties file: config.properties com.google.api.client.http.HttpResponseException: 400 Bad Request oauth_problem=timestamp_refused&oauth_acceptable_timestamps=1543578273941-1543578873941 at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070) at com.google.api.client.auth.oauth.AbstractOAuthGetToken.execute(AbstractOAuthGetToken.java:73) at com.soctronics.ims.atlasian.oauth.JiraOAuthClient.getAndAuthorizeTemporaryToken(JiraOAuthClient.java:37) at com.soctronics.ims.atlasian.oauth.OAuthClient.handleGetRequestTokenAction(OAuthClient.java:69) at com.soctronics.ims.atlasian.oauth.OAuthClient.execute(OAuthClient.java:51) at com.soctronics.ims.atlasian.oauth.ClientMain.main(ClientMain.java:18)