OAuth with Jira

Jira provides rich set of REST APIs for user interaction through automation. One can authenticate with these REST APIs in three different ways: 1) Using Basic Auth 2) Cookie based Auth and 3) Using OAuth Token

It’s recommended one should use last two options specially with OAuth Token. In this tutorial we will learn how to generate OAuth token that you can use within your code.

* Availability of OpenSSL command line
* Python 3
* Get Jira OAuth Generator library from Github


  • Clone Jira OAuth Generator library from GitHub
  • Python 3 Setup
    • Create Python Virtual Environment
      • mkvirtualenv -p python3 jira_oauth1_py3_env
    • Activate this environment to work on
      • workon jira_oauth1_py3_en
    • Install all required libraries
      • pip install -r requirements.txt
  • Generate RSA public and private keys
    openssl genrsa -out oauth.pem 1024
    openssl rsa -in oauth.pem -pubout -out oauth.pub
  • Performing OAuth Dance
    • Through Web browser login to Jira as a user for which you want to generate OAuth token.
    • From command line, run python script
      python jira_oauth_token_generator.py config/starter_oauth.config
    • Copy and paste link in browser as suggested. You will be asked to *Authorize / Decline* Upon authorization, you will get final access token information.
      • This oauth_token and oauth_token_secret data points you will need later to authenticate yourself while using OAuth with Jira.

How to use OAuth to access Jira

Couple of ways you can Access using Python.

1. Using Python Jira library (recommended):
Take a look at access_using_jira_library.py to find out how you can use OAuth with this library.
(jira_oauth1_py3_env) ➜ jira-oauth-generator git:(master) ✗ python access_using_jira_library.py config/final_oauth_token.config

Retrieving Issue: EXJIRA-123
Issue: EXJIRA-123,  Summary: Deploy new JIRA Version

Retrieving 1st 3 Jira Projects available to you
First 3 Projects are [‘ABC’, ‘EDF’, ‘EXJIRA’]

2. Using bare bones Jira REST API along with Requests Library:
Take a look at access_using_requests_package.py to find out how you can use OAuth to access Jira with out box REST APIs.
(jira_oauth1_py3_env) ➜ jira-oauth-generator git:(master) ✗ python access_using_requests_package.py config/final_oauth_token.config

Retrieving 1st Jira Project available to you
(ABC) American Born Car

Adding comment to issue ABC-123
Comment successfully added. Please verify through browser!