Jira OAuth integration

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

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.

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) {
throw new JiraException();
return response;

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

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.


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

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.

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)

Hi Ian,

Thanks for your prompt help. It’s actually worked out.

Here i have another question, that by using JIRA OAuth with accessToken for API /rest/api/2/issue/{issueIdOrKey}/comment when any user comments it’s saving commented by (xxx) with same user for all. How can it be solved?

Actually in Basic authentication we pass username and password to the request but in OAuth how can send username?

Please help to move further… Thanks.


You’re welcome, @janardhanreddy.bored. With what you’re experiencing, I am assuming the username of the user who did the OAuth dance is being the requestor all the time. This is as expected since only that resource owner is authenticated and you’re using their tokens. To get through this, each user should go through the authentication process (OAuth dance), keep their unique tokens, and use those when doing authenticated requests.


Thanks Ian. I got your solution and it means allot to me…

I’m facing other issue that I have created a new standalone app for communicating to JIRA to get requestTokens and getting proper response. and the same source code & dependencies has been copied to my existing project and trying to get requestToken but getting below error
401 Unauthorized

Could you please suggest me what am’i doing wrong…


I have not encountered that error yet, but you might want to check this Knowledge Base article to shed some light. You might have overlooked something when you copied from one app to the other.