I am using the JIRA Python plugin (https://github.com/pycontribs/jira#jira-python-library) to connect to JIRA with the below py code. I worked with Atlassian Python plugin as well with different py code but ended up with another error "AttributeError: 'dict' object has no attribute 'auth'". Because of this I moved to JIRA Python plugin which showed some progress but then stuck again. Copied the Jira cookies from chrome browser.
from jira import JIRA
JiraCookies = [
{
"domain": "jira.domain.com",
"hostOnly": True,
"httpOnly": False,
"name": "atlassian.xsrf.token",
"path": "/",
"sameSite": "unspecified",
"secure": True,
"session": True,
"storeId": "0",
"value": "have-some-code",
"id": 1
},
{
"domain": "jira.domain.com",
"hostOnly": True,
"httpOnly": True,
"name": "JSESSIONID",
"path": "/",
"sameSite": "unspecified",
"secure": True,
"session": True,
"storeId": "0",
"value": "have some code",
"id": 2
}
]
server = 'server'
usrnme = "uid"
pwd = "pwd"
jira_instance = str(JIRA(auth=(usrnme, pwd), options={'server': server,'cookies': JiraCookies[0]}))
jira_instance.issue(key = "Issue-123", fields = ["issuetype", "status", "summary"])
I get the below error. Please help with what I am missing.
Traceback (most recent call last):
File "U:\Profile\K\projects\Jira-Python\atlassianInstall.py", line 33, in <module>
jira_instance = str(JIRA(auth=(usrnme, pwd), options={'server': server,'cookies': JiraCookies[0]}))
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\client.py", line 462, in __init__
user = self.session(auth)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\client.py", line 2446, in session
r = self._session.post(url, data=json.dumps(authentication_data))
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\resilientsession.py", line 154, in post
return self.__verb('POST', url, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\resilientsession.py", line 125, in __verb
response = method(url, timeout=self.timeout, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 528, in request
prep = self.prepare_request(req)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 456, in prepare_request
p.prepare(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 318, in prepare
self.prepare_cookies(cookies)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 575, in prepare_cookies
cookie_header = get_cookie_header(self._cookies, self)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\cookies.py", line 142, in get_cookie_header
jar.add_cookie_header(r)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\http\cookiejar.py", line 1367, in add_cookie_header
attrs = self._cookie_attrs(cookies)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\http\cookiejar.py", line 1326, in _cookie_attrs
self.non_word_re.search(cookie.value) and version > 0):
TypeError: expected string or bytes-like object
If I remove "cookies" from options, I get the below error:
WARNING:root:Got recoverable error from POST https://jira.domain.com:444/rest/auth/1/session, will retry [2/3] in 3.953182659843959s. Err: HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))
WARNING:root:HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'))) while doing POST https://jira.domain.com:444/rest/auth/1/session [{'data': '{"username": "uid", "password": "pwd"}', 'headers': {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json,*.*;q=0.9', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json', 'X-Atlassian-Token': 'no-check'}}]
WARNING:root:Got ConnectionError [HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))] errno:None on POST https://jira.domain.com:444/rest/auth/1/session
{'response': None, 'request': <PreparedRequest [POST]>}\{'response': None, 'request': <PreparedRequest [POST]>}
WARNING:root:Got recoverable error from POST https://jira.domain.com:444/rest/auth/1/session, will retry [3/3] in 29.1680272787147s. Err: HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))
WARNING:root:HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)'))) while doing POST https://jira.domain.com:444/rest/auth/1/session [{'data': '{"username": "uid", "password": "pwd"}', 'headers': {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json,*.*;q=0.9', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json', 'X-Atlassian-Token': 'no-check'}}]
Traceback (most recent call last):
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "U:\Profile\K\projects\Jira-Python\atlassianInstall.py", line 33, in <module>
jira_instance = str(JIRA(auth=(usrnme, pwd), options={'server': server}))
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\client.py", line 462, in __init__
user = self.session(auth)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\client.py", line 2446, in session
r = self._session.post(url, data=json.dumps(authentication_data))
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\resilientsession.py", line 154, in post
return self.__verb('POST', url, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\resilientsession.py", line 146, in __verb
raise exception
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\jira\resilientsession.py", line 125, in __verb
response = method(url, timeout=self.timeout, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='jira.domain.com', port=444): Max retries exceeded with url: /rest/auth/1/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))