Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SOLVED: How do I authenticate for Confluence in the Atlassian Python API?

Edited

SOLVED: Found out that I needed to use the space code instead of its actual name when creating the confluence page.

I have been trying to figure out for hours how to use the Atlassian Python API to do anything in Confluence, and I just can't for the life of me figure out how to authenticate. According to this documentation of the API, I should be able to do this

confluence = Confluence(
    url='http://localhost:8090',
    username='admin',
    password='admin')

 But it just doesn't work. Another option it gives is a key/cert authentication and I can't figure out how to set that up, and another option is Oauth, and I've looked at probably 5 different pages trying to figure out how to enable that somehow but nothing tells me where the setting is.

I'm just so lost. Any help would be greatly appreciated. Thank you.

2 answers

1 accepted

0 votes
Answer accepted
Daniel Eads Atlassian Team Oct 01, 2020

Hello Daniel, welcome to the Community!

I'm glad you were able to sort this question out and get the python library working with your local Confluence Server instance. We're here to answer any additional questions if they come up!

Cheers,
Daniel | Atlassian Team

Hi,

Can you please provide the example/answer. I am not able to figure out how to authenticate using the api?

It turned out that the confluence function I used in my original question wasn't the actual problem for me. What it turned out was that in the create function, I was using the actual name of the space for the space name argument, when it actually needed the three-digit code for the space. So for example my space name was "Test", but its code was "TES". I had been using "Test" for the space name but I needed to use "TES".

If this isn't your problem, then I can tell you that another problem I had, which was figuring out what to use for the confluence function that is shown in the original question. For username, use your email. For password, use an API token.

Like Nikhilesh Saggere likes this

Thank you Daniel for your response!

I tried using the below mentioned to get authenticated to the confluence page and extract the information. 

# coding=utf-8
from atlassian import Confluence

confluence = Confluence(url="http://confluence.companyname.com", username="user1", password="passkey")

# If you know Space and Title
content1 = confluence.get_page_by_title(space="SPACE", title="page title")

print(content1)

# If you know page_id of the page
content2 = confluence.get_page_by_id(page_id=1123123123)

print(content2) 

 However, i get the following error, when the above snippet is executed

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 401 Client Error:  for url: https://confluence.sw.companyname.com/rest/api/content?start=0&limit=1&spaceKey=SPACE&title=title

Going by the error code 401; it is still an authentication failure. 

From https://community.atlassian.com/t5/Confluence-questions/No-more-Python-API-working-for-Confluence/qaq-p/1075027 the API token method is the only way forward.

 

Could you please provide me an example or point me to the code snippet where the API method is used to get the authentication step passed and able to extract the info.

I have generated the API key, but not sure how to use it the atlssaina-python API methods.

Please help.

Many Thanks!!

Hi Nikhilesh, did you have any luck resolving this?

yes please use curl utility in linux or requests module in python

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,761 views 8 32
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you