How to set up OAuth authentication for JIRA REST API in a Node.js application?

I’m trying to create a Node.js app that can make new JIRA issues. I want to use OAuth for user authentication, but I’m having trouble figuring it out. The Atlassian docs aren’t very helpful for beginners.

Can someone explain how to:

  1. Set up the JIRA application link
  2. Create a basic Node.js app that connects to JIRA using OAuth

I’m using JIRA version 6.0.4 and I’m pretty new to both JIRA and OAuth. Any help or examples would be great! I’ve looked around but can’t find a clear explanation that covers both parts.

Thanks in advance for any advice or resources you can share!

Setting up OAuth for JIRA API in Node.js can be complex, but it’s doable. First, ensure you’ve created an application link in JIRA with the correct permissions. For the Node.js part, I recommend using the ‘atlassian-oauth’ package. It simplifies the OAuth process significantly.

Start by installing the package and initializing it with your consumer key and secret. Then, implement the OAuth flow: request token, user authorization, and access token exchange. Once you have the access token, you can make authenticated API calls.

A crucial tip: use environment variables for sensitive data like keys and secrets. Also, implement proper error handling and token refresh mechanisms.

For creating JIRA issues, the ‘jira-connector’ package works well with OAuth tokens. It provides a clean interface for various JIRA operations.

Remember, OAuth tokens expire, so build in a way to refresh them automatically in your application logic.

hey, oauth can be a pain! i’ve used the ‘axios’ library for jira api calls. it’s pretty simple. just set up your oauth creds in the headers. for the app link, make sure ur callback url is correct. don’t forget to handle token refreshes - they expire quick! good luck with ur project!

I’ve been through this OAuth setup for JIRA myself, and it can be tricky. Here’s what worked for me:

For the JIRA application link, go to your JIRA admin settings and create a new application link. You’ll need to generate a consumer key and shared secret. Make sure to save these.

On the Node.js side, I used the ‘oauth’ npm package. You’ll need to implement a three-legged OAuth flow. First, get a request token from JIRA, then redirect the user to authorize, and finally exchange the request token for an access token.

The trickiest part for me was handling the callback URL. Make sure it matches exactly what you set in JIRA.

Once you have the access token, you can use it to make authenticated requests to the JIRA API. I found the ‘jira-client’ package helpful for this.

Remember to keep your consumer key and shared secret secure. Don’t commit them to version control.

Hope this helps point you in the right direction. Let me know if you need more specifics on any part of the process.