Java OAuth Example does not work

Hi there,

I’ve been trying to follow this example here:

When I get to this step:

$ java -jar target/OAuthTutorialClient-1.0.jar requestToken

I get:

May 12, 2017 8:18:34 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="redacted", oauth_problem="consumer_key_unknown"} 401 Unauthorized
	at com.atlassian.oauth.client.example.JiraOAuthClient.getAndAuthorizeTemporaryToken(
	at com.atlassian.oauth.client.example.OAuthClient.handleGetRequestTokenAction(
	at com.atlassian.oauth.client.example.OAuthClient.execute(
	at com.atlassian.oauth.client.example.ClientMain.main(

Is there something that could be preventing this from working that isn’t documented? I’ve setup an example application in our JIRA installation under the Application Links. I’m not sure how to investigate since we don’t host JIRA where I can look at the logs

I found the problem. There’s a typo in the documentation. It says to set the Consumer key to OAuthKey when setting up the Application Link. But this is wrong by 1 character, it’s actually a lower-case a as in OauthKey.

Sigh. :frowning:


Thanks for reporting this @kevin1. I opened a PR here to fix the docs and added you as a reviewer.

1 Like

I m still getting this error 401

could this be due to some issue in keys, or is it the consumer type.
I have corrected the typo issue as well, but this error is still coming…

I am getting this 401 error. Same output as the OP but I have the correct Consumer_Key in my program files and application links

I am not sure if that is still a problem, but I had to make sure that jira_home url is set in a proper format in order to make everything work correctly.


not that there is \: after https and no trailing slash


This saved my day, thanks!

1 Like

@ChandanKumar welcome to the Atlassian developer community.

And for any others stumbling across this thread, please be aware that OAuth 1.0a remains for legacy reasons (it’s right there in the title); however, there is a much better supported and easier to implement OAuth 2.0 option. OAuth 2.0 wasn’t available at the time of the original post, but if you are just starting work on a REST API client now, our recommendation would be the newer auth method.