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.
what is page_data_json?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello All,
First of all it is worth noting atlassian-python-api is an open source project, it is not owned/maintained by Atlassian.
You can use personal assess token with this library, the only difference is in syntax between cloud and data-center:
from atlassian import Jira
# To be used with Jira cloud
jira_cloud = Jira(url="<url>", username="username", password="password")
# Use with data-center
jira_dc = Jira(url="url", token="<token>>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.