OAuth Token generation gives 404 error

Following this link https://developer.atlassian.com/server/jira/platform/oauth/

At Step 2. Do the “OAuth dance: java -jar OAuthTutorialClient-1.0.jar requestToken

Getting the following error

com.google.api.client.http.HttpResponseException: 404 Not Found
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Oops, you&#39;ve found a dead link. - JIRA</title><script type="text/javascript">contextPath = "";</script><link type='text/css' rel='stylesheet' href='/static-assets/metal-all.css' media='all'><script src='/static-assets/metal-all.js'></script><!--[if lt IE 9]><link type='text/css' rel='stylesheet' href='/static-assets/metal-all-ie.css' media='all'><script src='/static-assets/metal-all-ie.js'></script><![endif]--><!--[if IE 9]><link type='text/css' rel='stylesheet' href='/static-assets/metal-all-ie9.css' media='all'><![endif]--><meta name="decorator" content="none" /></head><body class=" error-page error404"><script type="text/javascript">document.body.className += " js-enabled";</script><div id="page"><header id="header" role="banner"></header><!-- #header --><section id="content" role="main"><div class="aui-page-panel"><div class="aui-page-panel-inner"><section class="aui-page-panel-content lowerContent"><div id="error-state"><span class="error-type"></span><h1>Oops, you&#39;ve found a dead link.</h1><ul><li>Go back to the <a href="javascript:window.history.back()">previous page</a></li><li>Go to the <a href="/secure/MyJiraHome.jspa">Home Page</a></li></ul></div></section><!-- .aui-page-panel-content --></div><!-- .aui-page-panel-inner --></div><!-- .aui-page-panel --></section><!-- #content --><footer id="footer" role="contentinfo"><section class="footer-body">


<ul class="atlassian-footer">
    <li>
        Atlassian JIRA <a class="seo-link" rel="nofollow" href="https://www.atlassian.com/software/jira">Project Management Software</a>



        <span id="footer-build-information">(v7.2.9#72011-<span title='d6cf5f35263cb0451bff611940e6cb537ecc0956' data-commit-id='d6cf5f35263cb0451bff611940e6cb537ecc0956}'>sha1:d6cf5f3</span>:node3)</span>
    </li>
    <li>
        <a id="about-link" rel="nofollow" href="/secure/AboutPage.jspa">About JIRA</a>
    </li>
    <li>
                        <a id="footer-report-problem-link" rel="nofollow" href="/secure/CreateIssue!default.jspa">Report a problem</a>
    </li>
</ul>
<div id="footer-logo"><a href="http://www.atlassian.com/" rel="nofollow">Atlassian</a></div></section></footer><!-- #footer --></div><!-- #page --></body></html>
	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.atlassian.oauth.client.example.JiraOAuthClient.getAndAuthorizeTemporaryToken(JiraOAuthClient.java:37)
	at com.atlassian.oauth.client.example.OAuthClient.handleGetRequestTokenAction(OAuthClient.java:69)
	at com.atlassian.oauth.client.example.OAuthClient.execute(OAuthClient.java:51)
	at com.atlassian.oauth.client.example.ClientMain.main(ClientMain.java:18)

Notes: Have followed the config steps perfectly, even tried to append /jira at the back of the URL

Hi @gautamsinghania95,

The trailing “/jira” should not be added, adding it will give the error you got above. Removing it, what is the error you get? I tried it just now and it works, my jira_home looks like

jira_home=https\://iangil.atlassian.net

wherein there is no trailing “/”, use https, and I escaped “:” (may not be necessary for some).

Cheers,
Ian

Hi @iragudo

I had tried that initially, and it does not work. Was trying with my server name (":" escaped, “/jira” not appended).

Gautam

What was the error you got when you removed /jira? I assume it is different than the “you’ve found dead link. - JIRA” message.

Here is the error message

Sep 13, 2018 8:28:41 AM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="https%3A%2F%2Fjira.global.tesco.org", oauth_problem="consumer_key_unknown"}
com.google.api.client.http.HttpResponseException: 401 Unauthorized
oauth_problem=consumer_key_unknown
	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.atlassian.oauth.client.example.JiraOAuthClient.getAndAuthorizeTemporaryToken(JiraOAuthClient.java:37)
	at com.atlassian.oauth.client.example.OAuthClient.handleGetRequestTokenAction(OAuthClient.java:69)
	at com.atlassian.oauth.client.example.OAuthClient.execute(OAuthClient.java:51)
	at com.atlassian.oauth.client.example.ClientMain.main(ClientMain.java:18)

Thanks! Now it’s a lot clearer. To break down the errors you have so far:

  1. Status 404 with dead link - this is caused by appending /jira in jira_home. Remove it and you should be fine.
  2. Status 401 with “oauth_problem=consumer_key_unknown” - this is caused by a mismatch between the consumer_key in your config.properties and the consumer key you placed in the Link Applications dialog mentioned in Step 1 #4. Do take note that this is case sensitive.

Kindly double check those values, along with the keys used.

EDIT:
For #1, in server land, it depends on how your current setup is. It is possible that in some setup, a trailing /jira is necessary.

According to the link,

jira_home=https\://jira.global.tesco.org
consumer_key=OauthKey
private_key=<<My private key without line breaks>>

Also, the private key above should not contain -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----. Is this correct?

Yes, this is correct, no line breaks, and it should not contain those parts. If the private key is too long, it will give off a different error altogether. As for the consumer key in the application link, please make sure that the “Incoming Authentication” is filled out. By any chance can you provide a screen shot of that part? Please remove the Public Key part.

Will do so in some time.

Can you also tell me the supposed way to enter the public key in the box provided? Should -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- also be removed in this one?

Yes, I removed mine. No need to remove new line characters.

Hi @iragudo

Please see image-1 of the app setup.
image001

Gautam

Hi @iragudo

Please see image-2 of the app setup.

image002

Best,
Gautam

Hello, based on this image, you used tesco as the consumer key. Please update your config.properties and change Oauthkey to tesco to match your configuration in Jira. This mismatch is causing the status 401.

Thanks for the reply. It worked!!

Side Note : Is it recommended to use the consumer key as OauthKey, or setting it to other value?

You’re welcome and glad you were able to configure it properly. As for consumer key OauthKey is just a suggestion, but personally, feel free to set it with a value that can identify the service provider.

Cheers,
Ian