pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.91k stars 856 forks source link

API token length #1656

Open Patrykacz93 opened 1 year ago

Patrykacz93 commented 1 year ago

Bug summary

I have a problem with "login" to jira using username and API Token, the reason is that the API Token generates longer now.

image

Is there an existing issue for this?

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

9.7.1

jira-python version

3.2.0

Python Interpreter version

3.7

Which operating systems have you used?

Reproduction steps

1. Creating a class in which we use e-mail and API Token to log in.

2. Using the appropriate e-mail and the generated API Token.

Stack trace

-

Expected behaviour

-

Additional Context

No response

studioj commented 1 year ago

@Patrykacz93 can you state what the issue is? You dont specify the actual error or problem

Patrykacz93 commented 1 year ago

Below are the error logs that occur.

The problem is that several people use the application to generate reports. Login to the jira account is done using the email address and API key generated on Jira>Security.

For people who have generated a longer new API code, the following log is displayed. For people who have the old shorter API code everything works fine.

Application written in Python 3.7 using the jira library. The application is used to search for a case and generate a report in docx and pdf format.

Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\stusznio\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\stusznio\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run self._target(*self._args, self._kwargs) File "C:\Praca\GeneratorRMA\jira_autogen\main.py", line 414, in get_csd_data self.descriptiontext = textwrap.fill(self.sec_jira_user.take_csd_data(self.csd_var.get())[1], width=20) File "C:\Praca\GeneratorRMA\jira_autogen\jira_login.py", line 15, in take_csd_data for i in self.auth_jira.search_issues('project="Customer Service Desk" AND issuetype=RMA AND status!=resolved AND status!=rejected AND status!=done', maxResults=1000): File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\client.py", line 2930, in search_issues Issue, "issues", "search", startAt, maxResults, search_params File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\client.py", line 724, in _fetch_pages resource = self._get_json(request_path, params=page_params, base=base) File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\client.py", line 3624, in _get_json r = self._session.get(url, params=params) File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\resilientsession.py", line 195, in get return self.__verb("GET", str(url), kwargs) File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\resilientsession.py", line 189, in __verb raise_on_error(response, verb=verb, kwargs) File "C:\Praca\GeneratorRMA\jira_autogen\venv\lib\site-packages\jira\resilientsession.py", line 70, in raise_on_error kwargs, jira.exceptions.JIRAError: JiraError HTTP 400 url: https://globalcontrol5.atlassian.net/rest/api/2/search?jql=project%3D%22Customer+Service+Desk%22+AND+issuetype%3DRMA+AND+status%21%3Dresolved+AND+status%21%3Drejected+AND+status%21%3Ddone&startAt=0&validateQuery=True&maxResults=1000 text: The value 'Customer Service Desk' does not exist for the field 'project'.

response headers = {'Date': 'Wed, 17 May 2023 08:12:29 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': '71f78202b444ebd8842e9e82f0757279', 'X-Seraph-Loginreason': 'AUTHENTICATED_FAILED', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '91042fe5ae00851e', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Transfer-Encoding': 'chunked'}
response text = {"errorMessages":["The value 'Customer Service Desk' does not exist for the field 'project'.","Field 'issuetype' does not exist or this field cannot be viewed by anonymous users."],"warningMessages":[]}
princenyeche commented 11 months ago

@Patrykacz93 It seems that the API key isn't valid but that might not be the case if you generated a new token for this. Probably what you can do to ensure that this token works is try it on another tool such as Postman. Make a simple call to this endpoint https://yourinstance.atlassian.net/rest/api/3/myself validated with your new API token length and see if you get an OK status