...
Excerpt |
---|
If you are writing a script that interacts with Jira through a REST API, you should authenticate using an OAuth token, rather than an embedded username/password. Here we describe one way to do the 'oauth dance' to generate a trusted token using Python 3 - specifically the |
Warning | ||
---|---|---|
These instructions no longer work for me on tested combinations {Ubuntu 18.04 + Python 3.6.9}, { Ubuntu 20.04 + Python 3.8.5}. The
|
Table of Contents |
---|
Establishing OAuth trust
...
Install Python libraries
Code Block |
---|
pip3 install -U pip # upgrade pip to avoid "No module named 'setuptools_rust'" error
pip3 install jira ipython |
Expand | ||
---|---|---|
| ||
If you get an error:
then pip3 install -U pip should fix it. |
Generate an RSA public key
...
Code Block |
---|
BROWSER='echo %s' jirashell --server https://issues.redradishtech.com --consumer-key monitor-jira-license --key-cert rsa.pem --oauth-dance |
Expand | ||
---|---|---|
| ||
If, instead of printing a URL, the jirashell command just prints:
That means your |
Expand | ||
---|---|---|
| ||
Jirashell would normally try to launch your preferred web browser, using the webbrowser library. By setting the BROWSER env variable, we tell Python not to bother, and just print the URL for us to manually cut & paste. This is required for server environments, where |
This should print a URL. Open it in your browser
At this point you need to decide which JIRA user you want to grant OAuth access as. For most scripts you should create a dedicated JIRA role account with reduced privileges. Log out and back in to JIRA as that user, (or use switchuser.jsp) then open the link:
Click 'Allow' in the Browser window:
Note |
---|
If you have |
After the URL, your terminal also should have displayed:
...