Accessing Jira with python

Nikita Kiselev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2022

Hi! 
I'm trying to connect to Jira with python, using Atlassian Python API’s. I've generated Personal Access Token and is using code from your example here

I'm trying to run this script in my jupyter notebook:

{noformat}

from atlassian import Jira
jira = Jira(
url='https://my.jira.domain/',
token='my PAT'
)
jira.projects(included_archived=None)
{noformat}

And I get this error:

TypeError: __init__() got an unexpected keyword argument 'token'

 Can you please help me to solve it? Maybe you can provide me with more examples how to use this PAT for connecting to Jira? 

Thanks in advance

2 answers

0 votes
Gary Xu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2023

Instead of "token", you may use "token_auth"


from jira import JIRA
jira_connection = JIRA(
options={'server': 'https://xxxx.com'},
token_auth='yourPatTokenasdfqwerty'
)
0 votes
Aron Gombas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2022

Hmm, one thing I noticed: your code suggests you're using Jira Cloud, while the code examples in the page you linked are for Jira Server or Data Center.

Are you sure that you're using the correct code for the correct deployment type?

Nikita Kiselev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2022

Yes, you are right, there are different code examples for cloud and for Jira Sever, according to the link. 
And, if i got it right, the code I attached is for server, while for the cloud it should be like this, with API token.

jira = Jira(
    url='https://your-domain.atlassian.net',
    username=jira_username,
    password=jira_api_token,
    cloud=True)

 I've attached screen with this part of documentation.Screenshot_1.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events