Open hialvaro opened 1 year ago
Could you check if the just released 3.5.1 has any improved behaviour?
I was only able to get this to work with jira 3.5.1 with the following, only passing one of the auth methods wouldn't work, but when I passed both I was able to access without auth errors.
jira = JIRA(server="https://somecompany.atlassian.net",
basic_auth=(jira_email, jira_token),
options={"headers": {"Authorization": f"Basic {jira_token}"}})
I'll whip up a pull request where we use the HTTPBasicAuth class from requests to see if it helps.
It's quite strange that our Jira Cloud test suite passes. For now that is the only difference that comes to mind
Actually, something just came to mind. Are we using the correct token here?
This client is leveraging the requests
library that is already base64 encoding the email:token, https://github.com/psf/requests/blob/6e5b15d542a4e85945fd72066bb6cecbc3a82191/requests/auth.py#L62-L64 .
If you are able to pass a raw header of f"Basic {jira_token}"
that suggests to me that you are using the incorrect token.
Could you elaborate further on what token you are using and where you are getting it from?
Here are the links to the Atlassian docs that may help: https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/#supply-basic-auth-headers
In my case this solved the problem
ACCESS_TOKEN = ""
CLOUD_ID = ""
options = {
'server': f'https://api.atlassian.com/ex/jira/{CLOUD_ID}'
# "headers": {
# 'Authorization': f'Bearer {ACCESS_TOKEN}'
# }
}
j = JIRA(
options=options, token_auth=ACCESS_TOKEN)
For some weird reason, it was not working, was getting the same error as mentioned in the bug summary, but the same code then started working by itself. Not sure why, below is the code for reference
from jira import JIRA
jira_token = 'token'
jira = JIRA(
server='https://myorg.atlassian.net',
basic_auth=('my@email.com', jira_token),
)
print(jira.issue('ORG-301').fields.summary)
Same code as in the docs, but still sharing.
Bug summary
When trying to authenticate Jira, I use the following, as the docs indicate:
However, I am getting the following error:
However, if I use it like this:
It works perfectly. Is there some issue with token authentication? Am I missing something?
Is there an existing issue for this?
Jira Instance type
Jira Cloud (Hosted by Atlassian)
Jira instance version
No response
jira-python version
3.5.0
Python Interpreter version
3.9
Which operating systems have you used?
Reproduction steps
Getting the following error:
Expected behaviour
Authenticate and proceed to what I need to do.
Additional Context
No response