pycontribs/jira

3.0.1 - JiraCookieAuth - TypeError: session() takes 1 positional argument but 2 were given when creating a JIRA instance with auth=(username,password)

Closed this issue ยท 11 comments

Before raising any bug be sure that you used the latest release and that it still reproduces with the latest master. No other version is supported.

Describe the bug
Using the new package published an hour ago, I get a runtime arg error when opening a connection.

To Reproduce

$ python3                                                                                              
Python 3.8.5 (default, Jan 27 2021, 15:41:15)                                                          
[GCC 9.3.0] on linux                                                                                   
Type "help", "copyright", "credits" or "license" for more information.                                 
>>> from jira import JIRA                                                                              
>>> username = 'tevert@motus.com'                                                                      
>>> password = '<REDACTED>'                                                                           
>>> conn = JIRA('https://jira.motus.com', auth = (username, password))                                 
Traceback (most recent call last):                                                                     
  File "<stdin>", line 1, in <module>                                                                  
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 496, in __init__         
    user = self.session()                                                                              
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 2980, in session         
    r = self._session.get(url)                                                                         
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 172, in get    
    return self.__verb("GET", url, **kwargs)                                                           
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/resilientsession.py", line 143, in __verb 
    response = method(url, timeout=self.timeout, **kwargs)                                             
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 543, in get        
    return self.request('GET', url, **kwargs)                                                          
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request    
    resp = self.send(prep, **send_kwargs)                                                              
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/sessions.py", line 650, in send       
    r = dispatch_hook('response', hooks, r, **kwargs)                                                  
  File "/home/tevert/.local/lib/python3.8/site-packages/requests/hooks.py", line 31, in dispatch_hook  
    _hook_data = hook(hook_data, **kwargs)                                                             
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 199, in handle_401       
    self.init_session()                                                                                
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 215, in init_session     
    self.start_session()                                                                               
  File "/home/tevert/.local/lib/python3.8/site-packages/jira/client.py", line 229, in start_session    
    self._get_session(self.__auth)                                                                     
TypeError: session() takes 1 positional argument but 2 were given                                      
>>>                                                                                                    
  1. Any additional steps or considerations that happen before or after.

Expected behavior
I get a connection

Stack Trace

A code block with the any trace messages.

Version Information
Type of Jira instance:

  • [ ] Jira Cloud (Hosted by Atlassian)
  • [ X ] Jira Server or Data Center (Self-hosted)
    Python Interpreter: 3.8
    jira-python: 3..0.1
    OS: WSL Ubuntu
    IPython (Optional):
    Other Dependencies:

Additional context
Add any other context about the problem here.

To clarify, this exact code was working fine this morning with version 2.0.0

Thx for your issue. I'll help investigate this afternoon.
It's maybe related to the auth changes in jira cloud which we try to support.
@tevert
Do you know which version of jira server you're running?

I can repro on jira v8.5.4 => that's a start

i think the "auth" parameter was "potentially" misused in prev versions or worked by accident. I don't know the exact history of those parameters.
maybe @ssbarnea could enlighten us (maybe related to commit a4e6b1b )

could you try

conn = JIRA('https://jira.motus.com', basic_auth=(username, password))  

that seems to work for me

if this is the case we might need to add something in the readme to warn people about the changes in v3.0.0

I was going to point you to the documentation here https://jira.readthedocs.io/en/master/api.html#jira.JIRA but i see the documentation for auth is not properly generated. => PR #1038 will fix that

following example in the documentation shows though the usecase you're pointing to
https://jira.readthedocs.io/en/latest/examples.html#cookie-based-authentication
which would suggest that it should work.

I'll start a branch which at least adds a failing test for this

basic_auth works fine, thanks for the quick update!

@ssbarnea maybe we should also raise a deprecation warning here when people are using Jira Cloud?

its not yet deprecated for jira server so it should work here

https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

+1 on cookie based auth.
I have an instance with generic basic_auth in front of Jira for additional security layer.
ty

@ssbarnea cookie based login is still broken for jira server...
Was this automatically closed?

Based on what I see on screen it seems that that merge did close this ticket even if it did not had a "fixes: #num" block on it. A glitch in the github matrix? Next time just reopen if you think appropiate.

Jc-L commented

Is there a workaround for this (other than downgrading to 2.0.0) ? It is still failing in the last version

JIRA('https://jira.mydomain.com', auth = (username, password))
[...]
TypeError: session() takes 1 positional argument but 2 were given