Allow Personal Access Token authentication

Ventsislav March 9, 2021

I am using Jira Software 8.15 and I have create a PAT (Personal Access Token) and I am trying to authenticate using jira-python's basic_auth.

 

When I use the token I just created I get the following error:

Authentication Failure - Reason : AUTHENTICATED_FAILED

and when I look at the security logs:

<user> tried to login but they do not have USE permission or weren't found. Deleting remember me cookie

However!!

When I use username and password it all works as expected.

 

So, my question is is there any configuration that I need to change in order to make those PATs usable or is it the case that I can only use username:password to authenticate with Jira Server?

 

 

2 answers

1 vote
Ventsislav April 16, 2021

I believe I found the answer I was looking for here

 

host = "YOUR_JIRA_URL"
pat = "YOUR_PERSONAL_ACCESS_TOKEN"

headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
headers["Authorization"] = f"Bearer {pat}"
jira=JIRA(server=host, options={"headers": headers}) 
0 votes
Prince Nyeche
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 9, 2021

Hi @Ventsislav 

With cookies you use username:password, what syntax do you use with PAT? 

Ventsislav March 11, 2021

I am using jira-python and more specifically:

JIRA(
    basic_auth=(
        validated_data['email'],
        validated_data['token']
    ),
    options={
        'server': url,
        'agile_rest_path': 'agile',
    },
    max_retries=0,
)

it works just fine with jira cloud, but when it comes to jira server it's not happy with the token - it only accepts password.

 

However, I managed to overcome this by installing this app

Like Prince Nyeche likes this

Suggest an answer

Log in or Sign up to answer