Jira app link woes (OAuth)

Michael Hoskins January 23, 2020

Hi folks,

I've been struggling to get an app link working in Jira to support a new app using OAuth. I've followed this doc (both with the example 'OauthKey' consumer_key and a randomly generated one via uuidgen which some examples suggested):

https://developer.atlassian.com/server/jira/platform/oauth

I always get:

{ statusCode: 401, data: 'oauth_problem=consumer_key_unknown' }

This wasn't much help, since I'm working with a freshly configured app link based on the docs:

https://confluence.atlassian.com/applinks/oauth-troubleshooting-guide-790632058.html#OAuthtroubleshootingguide-OAuthunknownkey

When that didn't work, I spent a lot of time searching the forum and Google with mixed results...the main takeaway is a lot of people hit the same problem, but many threads trail off with no clear resolution. Some suggest hard coding the consumer key to magic values like hardcoded-consumer, this was one of the more informative:

https://community.atlassian.com/t5/Jira-questions/How-to-get-consumer-key-for-jira-Oauth1/qaq-p/49925

The date made me suspect accuracy though, and other much newer suggestions pretty much mirror the official docs:

https://www.redradishtech.com/display/KB/How+to+write+a+Python+script+authenticating+with+Jira+via+OAuth

However, no amount of tinkering with the consumer key, naming, UI options, generating different length/format keys, etc. seems to get me past this error. I can't imagine this is so difficult (I've configured OAuth before for other services), what am I missing?

I am using Node.js, and have experienced the same behavior with different jira client wrappers from NPM including jira-client and jira-connector. The same work fine with username/password, so I don't think it's simply a code/library issue.

Thanks for any help!

1 answer

0 votes
Michael Hoskins February 5, 2020

Bueller, Bueller...  HALP!  :-)

Seriously, I'm taking silence to mean I've probably just missed something obvious. Just getting a chance to circle back and take another pass at this (was using local creds to move forward on other dev tasks)...but if anyone has similar experiences/good guides to share I would be most grateful. I'll post back with more detailed questions after I hack on this a bit more tonight.

Michael Hoskins February 5, 2020

Got a bit further just following the doc again... the only thing I did differently was make my app link "primary" in the UI (there are a few others configured by different teams)! Not sure if that should matter, but other than that I just followed the examples in the oauth doc verbatim (minus changing app name and key) and got success. That was from Node.js and jira-connector using the additional docs/util functions in their docs:

https://www.npmjs.com/package/jira-connector

I also found this useful:

https://confluence.atlassian.com/jiracoreserver073/allowing-oauth-access-861257138.html

I'm able to get an approval URL, token and token secret now. I go to the approval URL, approve and get a verifier code. However, when I try to use the code to get the oauth token I always get:

{ statusCode: 401, data: 'oauth_problem=token_expired' }

From other threads I gather the oauth tokens don't expire unless removed via profile > ... > access-tokens...but not sure if this is some sort of request token/verifier code timeout or I'm doing something else wrong. Trying various things now, but would appreciate any input. TIA!

Michael Hoskins February 5, 2020

I don't know what the time limit is between verification and requesting the oauth token, but this seems to have just been a timing issue. When I was just running the jira-connector util function to get the token/verify url, manually visiting the site, approving, grabbing the verifier code, and then running another function manually (still as fast as I could, but some seconds in between steps) it would always give me token_expired. Simply fully automating the process to reduce time between verifier and swapping for the token seems to work.

Suggest an answer

Log in or Sign up to answer