Source

atlassian-oauth-examples / python-requests /

Filename Size Date modified Message
..
2.3 KB
2.1 KB

JIRA OAuth in Python

A simple command-line example of the JIRA OAuth workflow in Python for use with jira-python.

Like jira-python, this example uses the popular requests and requests-oauthlib libraries.

These libraries do most of the heavy lifting which makes using the JIRA REST API with OAuth relatively simple.

Prerequisites

  1. Generate a public/private RSA key pair. This example will need to be able to read the rsa.pem file from disk.
  2. An OAuth Consumer configured under Application Link in your JIRA administration section. It should be configured with "Incoming Authentication" using the RSA key generated above.

Dependencies

Installing jira-python should take care of most of the dependencies. However, here are some of the key packages that get installed as dependencies of jira-python:

Running the Example

  1. Configure the "constants" toward the top of the script for your JIRA instance and OAuth Consumer.
  2. Run the script with python example.py.
  3. When prompted, open the link printed to the screen in your web browser and click the "Approve" button to authorize the app.

Pro Tip

  • If you need tighter control over parsing the responses and exception handling, you can use OAuth1 in place of OAuth1Session. See OAuth 1 Workflow for more information.