Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error while connecting Python to Confluence server using confluence PAT

girija kakani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 22, 2025

I have been trying to connect python to my org confluence server which is SSO enabled.

I have used the below python script but getting 401 error. However when I tried the same for personal account with no SSO enable it worked. I generated the PAT within confluence settings.

import os
from atlassian import Confluence

confluence = Confluence(
    url=os.getenv("CONFLUENCE_URL"),
    username=os.getenv("CONFLUENCE_USER"),
    password=os.getenv("CONFLUENCE_TOKEN")
)

if confluence.page_exists(space="myspacename", title="myspacetitle"):
    print("page exists")
else:
    print("page not found")

1 answer

0 votes
Jim Knepley - ReleaseTEAM
Atlassian Partner
October 22, 2025

Hi @girija kakani 

I wonder if you need to authenticate to Confluence cloud slightly differently:

from atlassian.confluence import ConfluenceCloud

confluence_cloud = ConfluenceCloud(
url="https://your-domain.atlassian.net",
token="your-api-token"
)

 

...as opposed to using the username and password parameters, which is what we used back in the server/datacenter days.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events