pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.94k stars 860 forks source link

Token Authentication with Jira Server, 401 error #1627

Closed amethystace11 closed 1 year ago

amethystace11 commented 1 year ago

Bug summary

Unable to authenticate to local jira server using Personal Access Token authentication. Working 100% fine with username, password authentication, just unable to get token_auth working. Receiving 401 response with error response headers when attempting to use token authentication. Built following https://github.com/pycontribs/jira/blob/main/docs/examples.rst and https://buildmedia.readthedocs.org/media/pdf/jira/latest/jira.pdf . Any help is greatly apprecaited! Some sections of tokens, dns names, etc, censored for privacy reasons with "[REDACTED]", fyi.

Is there an existing issue for this?

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

9.0.0

jira-python version

3.4.1

Python Interpreter version

3.8.14

Which operating systems have you used?

Reproduction steps

# 1. Given a Jira client instance
jira: JIRA

apikey = "[REDACTED]"
server = "[URL HERE]"

options = { 'server' : server, 'verify' : False }

# 2. When attempting to authenticate with Personal Access Token using:
jira = JIRA(options, token_auth=apikey)

# 3. Receiving 401 response from [URL:PORT]/rest/api/2/field

response headers = { 'X-AREQUESTID': '[ID]', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': 'sandbox', 'Strict-Transport-Security': 'max-age=[REDACTED]', 'X-AUSERNAME': 'anonymous', 'Cache-Control': 'no-cache, no-store, no-transform', 'WWW-Authenticate': '[REDACTED]', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': '[Today]', 'Keep-Alive': 'tiemout=20', 'Connection': 'keep-alive'}
response text = {"errorMessages":[],"errors":{}}

Stack trace

See above

Expected behaviour

Expecting authentication to work - please let me know if I'm missing part of this. Redacted certain bits of information for privacy purposes.

Additional Context

No response

Sholomb commented 1 year ago

@amethystace11 , I found that adding server as an argument in the JIRA object worked even though it's also included in my options.

JIRA(server=jiraURL, options=jira_options, token_auth=token)

amethystace11 commented 1 year ago

Closing issue, ended up generating a new token on Jira and issue seemed to fix itself.