JIRA OAuth in Python
A simple command-line example of the JIRA OAuth workflow in Python for use with jira-python.
These libraries do most of the heavy lifting which makes using the JIRA REST API with OAuth relatively simple.
- Generate a public/private RSA key pair. This example will need to be able to
rsa.pemfile from disk.
- 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.
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:
- PyCrypto (You may have to install this on your own depending on your operating system)
Running the Example
- Configure the "constants" toward the top of the script for your JIRA instance and OAuth Consumer.
- Run the script with
- When prompted, open the link printed to the screen in your web browser and click the "Approve" button to authorize the app.
- If you need tighter control over parsing the responses and exception handling,
you can use
OAuth1in place of
OAuth1Session. See OAuth 1 Workflow for more information.