atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.33k stars 660 forks source link

[DOC] How can we use this with a Jira or Confluence API token? #1112

Open eabase opened 1 year ago

eabase commented 1 year ago

The examples in the README only shows using U/P and not how to use a Personal Access Token (PAT).

How can we use this with a Jira or Confluence using a PAT API token?

nassauwinter commented 1 year ago

Hi,

That's easy:

jira = Jira(url="https://jira.example.com/", token="<your_token_here>")

You can find it here: https://github.com/atlassian-api/atlassian-python-api/blob/e704bb7df30d11397b8bc4f84feb8a2be0f5eec1/atlassian/rest_client.py#L20

gonchik commented 1 year ago

@eabase will it be helpful if we update README.md and index.rst? if so, how it will be better ?

eabase commented 1 year ago

@gonchik

Hi! Thanks for quick response and sorry for late answer. I certainly never found the index.rst file... So maybe provide a link from README.

Or using Personal Access Token Note: this method is valid for Jira Data center / server editions only! For Jira cloud, see below.

So, how do you determine if your company is using a Jira Data/Server center or a Cloud?

It would also be very helpful with a very basic example, for querying the available Confluence spaces or a Jira Epic, using JQL and connecting using a PAT.

eabase commented 1 year ago

This is not working. I get loads of errors, mostly timeouts or 401, depending.

The URI works in browser for JQL, but not from my py app, not. At least not according to your documentation above.

How do you increase the timeout for the request?


UPDATE

Apparently this doesn't work over a VPN, or it requires a lot more time.

Traceback (most recent call last):
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "C:\venvs\jira-ven\Lib\site-packages\urllib3\connection.py", line 179, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x00000271EDF04990>, 
'Connection to jira.tools.aws.xxxx.com timed out. (connect timeout=75)')