Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to connect to JIRA from python

This code works and prints out the list of projects accessible to anonymous user

---------------------This Works-----------

from collections import Counter
from jira import JIRA
import re

options = {
'server': 'https://jira.atlassian.com'}

jira = JIRA(options)

projects = jira.projects()
for v in projects:
print (v)

-------------------------THIS DOES NOT WORK-------

from collections import Counter
from jira import JIRA
import re


options = {
'server': 'https://jira.atlassian.com'}

jira = JIRA(options, basic_auth=('username', 'password'))

projects = jira.projects()
for v in projects:
print (v)

-------------------------------------ERROR-------------------

 WARNING:root:Got recoverable error from GET https://jira.atlassian.com/rest/api/2/serverInfo, will retry [1/3] in 17.384401903628806s. Err: 401
WARNING:root:Got recoverable error from GET https://jira.atlassian.com/rest/api/2/serverInfo, will retry [2/3] in 36.83359655277892s. Err: 401
WARNING:root:Got recoverable error from GET https://jira.atlassian.com/rest/api/2/serverInfo, will retry [3/3] in 58.065338652808876s. Err: 401 

-------------------------------------------------------

Please help with answer

 

3 answers

1 accepted

1 vote
Answer accepted

Hello,

It means that you are not authenticated in Jira. Are you sure that you provide valid credentials for basic_auth? Does your Jira instance use basic authentication?

Credentials are valid, since I could open the same JIRA link and provide my credentials and login. I use it daily via web.

How do I know if my JIRA instance uses basic authentication or not?

Thanks for your reply.

You are awesome Alexey!!! Got it working. There was an issue with the url which I gave, I had to remove "login.jsp" and it worked.

Thanks a lot!!!

You are welcome!

Hey! I think I have the same issue, can you share how I can see if my JIRA instance uses basic authentication or not? 

Thank you in advance! 

I think that the problem is in official Python library.

It works:

curl --user MY_JIRA_USER:MY_JIRA_PASSWORD -X GET
-H "Content-Type: application/json"
https://MY_JIRA_DOMAIN.atlassian.net/rest/api/latest/issue/MY_ISSUE_NUMBER

It's NOT works:

from jira import JIRA

server = 'https://MY_JIRA_DOMAIN.atlassian.net'
user = 'MY_JIRA_USER'
pass = 'MY_JIRA_PASSWORD'

options = {'server': server}
jira = JIRA(options=options, basic_auth=(user, pass))

print(jira.issue(MY_ISSUE_NUMBER))

I've got the correct response using terminal but not from Python.

It proves that my credentials and user permissions in Jira is fine.

I have same problem.

same problem.  please help

Suggest an answer

Log in or Sign up to
This widget could not be displayed.
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you