You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I can use the following for basic auth:
from atlassian import Confluence
confluence = Confluence(url='https://internalconfluenceurl.com', username = 'myusername', password='mypassword')
This also works if I use an API token value instead of password.
How do I alter this to use a Personal Access Token (as created within Confluence) instead? I tried substituting that in for the password, but it gives an error.
Is there a further authentication step that I am missing? I have managed to do something similar in Jira, but the same approach does not work for Confluence.
I found a different approach:
import requests
response = requests.post(base_url, data=page_data_json, headers={'Authorization': f'Bearer {pat}',"Accept": "application/json",'Content-Type': 'application/json'})
if response.status_code == 200:
print("Child page created successfully")
else:
print("Failed to create the child page. Status code:", response.status_code)
It is not quite as convenient as using the inbuilt Confluence function, but it seems to work.
Hi @nirabe Welcome to the Atlassian community.
Have you check the below document for how to use the PAT in Jira/Confluence instead of basic auth?
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html
Below is the example of using PAT same way you need to modify to use in Python script
curl -H "Authorization: Bearer <yourToken>" https://{baseUrlOfYourInstance}/rest/api/content
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sagar and thanks for the prompt reply.
Yes, I had seen the link you shared. I cannot use cURL. There have been some suggestions of using requests instead.
I may go down this route, but it seems much more complicated than the approach for Jira, which is odd.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.