darwinyip opened a new issue #11133:
URL: https://github.com/apache/airflow/issues/11133


   **Apache Airflow version**: 1.10.10
   
   **Environment**: Docker
   **Package**: apache-airflow-backport-providers-jira==2020.6.24
   
   **What happened**:
   
   JiraHook fails to connect to Jira server. However using the `jira` library, 
it connects fine.
   
   **How to reproduce it**:
   
   Connection:
   ```
   Name: jira
   Conn Type: JIRA
   Host: https://xxxxx.atlassian.net
   Login: username
   Password: password
   ```
   Using hook:
   ```
   from datetime import datetime
   
   from airflow import DAG
   from airflow.operators.python_operator import PythonOperator
   from airflow.providers.jira.hooks.jira import JiraHook
   
   
   def update_jira():
       jira_client = JiraHook(jira_conn_id='jira').get_conn()
   
   
   default_args = {
       "owner": "airflow",
       "depends_on_past": False,
       "start_date": datetime(2020, 9, 23),
       'schedule_interval': None,
   }
   
   with DAG('test-jira', default_args=default_args) as dag:
       jira_task = PythonOperator(
           task_id='jira_task',
           python_callable=update_jira
       )
   ```
   Error:
   ```
   ERROR - Failed to create jira client, jira error: JiraError HTTP 401 url: 
https://xxxxx.atlassian.net/rest/auth/1/session
        text: Login failed
        
        response headers = {...}
   Traceback (most recent call last):
     File 
"/usr/local/lib/python3.6/site-packages/airflow/providers/jira/hooks/jira.py", 
line 78, in get_conn
       proxies=self.proxies)
     File "/usr/local/lib/python3.6/site-packages/jira/client.py", line 462, in 
__init__
       user = self.session(auth)
     File "/usr/local/lib/python3.6/site-packages/jira/client.py", line 2446, 
in session
       r = self._session.post(url, data=json.dumps(authentication_data))
     File "/usr/local/lib/python3.6/site-packages/jira/resilientsession.py", 
line 154, in post
       return self.__verb('POST', url, **kwargs)
     File "/usr/local/lib/python3.6/site-packages/jira/resilientsession.py", 
line 147, in __verb
       raise_on_error(response, verb=verb, **kwargs)
     File "/usr/local/lib/python3.6/site-packages/jira/resilientsession.py", 
line 57, in raise_on_error
       r.status_code, error, r.url, request=request, response=r, **kwargs)
   jira.exceptions.JIRAError: JiraError HTTP 401 url: 
https://xxxxx.atlassian.net/rest/auth/1/session
        text: Login failed
   ```
   
   Using jira library works fine:
   ```
   jira = JIRA('https://xxxxx.atlassian.net', basic_auth=('username', 
'password'))
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to