atlassian-api / atlassian-python-api

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

Login via Personal Access Token into confluence #911

Open chlamprecht opened 2 years ago

chlamprecht commented 2 years ago

Since Version 7.9 of confluence (Server or DC) it is possible to use personal access tokens to login into the system.

Currently this works only for Jira. In the moment the token parameter isn't accepted for confluence.

It would be nice to use this feature for confluence too.

gonchik commented 2 years ago

Hi! I use personal token as password parameter: and it works well for Confluence.

could you share exact logs please?

chlamprecht commented 2 years ago

Hi,

sure, I use this code and I am getting the following error

    confluence = Confluence(
        url='https://confuence.xxx',
        token='token')
Traceback (most recent call last):
  File "guardian.py", line 52, in <module>
    token='xxx')
  File "confluence.py", line 38, in __init__
    super(Confluence, self).__init__(url, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'token'
boomjynx commented 2 years ago

@chlamprecht - try changing your code to this:

confluence = Confluence(url="https://confluenceinstance.atlassian.net/",
    username='your_username / email>',
    password= '<token>',
    cloud=True)

I had been struggling with this and the above worked for me.

chlamprecht commented 2 years ago

I tried your code, but i am getting an 401 - forbidden. Are you sure to use Cloud=true? Because i try to connect against a data center edition.

gthieleb commented 2 years ago

I have the same issue connecting with a personal access token to a datacenter edition of Confluence. Is this currently supported?

gthieleb commented 2 years ago

Update: It works when using token param instead of password:

confluence = Confluence(
    url='https://confluence.example.com',
    username=os.environ["CONFLUENCE_USER"],
    token=os.environ["CONFLUENCE_PASSWORD"],
    cloud=False)