pythonjirapython-jira

How to access jira from python


I am trying to access jira from python and one of the things I need to do is pull up a specific issue. However, when I do so, I am getting a HTTPERROR 403(Basic Authentication Failure- Reason: Authentication_Denied). I have already installed jira api using pip. I am not sure why the auth_jirais not working as intended.

Code:

from jira.client import JIRA
import os

jira_email = <my_email>
jira_token = os.environ.get(<jira_api_token>)
jira_server = {"server": "https://issues.mycompany.com/"}
auth_jira = JIRA(options = jira_server, basic_auth = (jira_email, jira_token))
issue = auth_jira.issue('myissue')
print(issue)

Error: Some of the error messages I got

<!--HTTPError403 -->
...
<p>Encountered a <code>&quot:403- Forbidden&quo;</code> error while loading this page.</p>
<p>Basic Authentication Failure- Reason: AUTHENICATION_DENIED</p>

Solution

  • So it appears that I had to get rid of jira_email and change my auth_jira to this:

    jira_token = os.environ.get(<jira_api_token>)
    jira_server = {"server": "https://issues.mycompany.com/"}
    auth_jira = JIRA(options = jira_server, token_auth = jira_token)