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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,225
Community Members
 
Community Events
176
Community Groups

How to access Confluence using personal access token for organization that requires 2FA

Edited

Hello,

I am trying to access pages via the `atlassian-python-api` library in Python. I have read through this page on authentication and tried every method, but none of them have worked for me. Each attempt, I get a 401. I have created a personal access token both through my Atlassian account, as well as directly on Confluence. Below is a code snippet - my assumption is that I am getting 401 every time due to the 2FA requirement. What is the right way to fix this so I can get access to my organization's Confluence pages via python?

 

Additionally, is there a login method that is something similar to opening a browser and having the user login to their Confluence account there, instead of using an API token?

 

from atlassian import Confluence

email = 'me@org.com'
confluence_api_token = 'confluenceApiToken'
atlassian_api_token = 'atlassianApiToken'

confluence = Confluence(
url=domain,
username=email,
password=confluence_api_token,
cloud=True)


confluence.get_all_spaces(start=0, limit=5, expand=None)

 

 

2 answers

Hey, Matthew. I am facing a similar problem. Were you able to come up with a solution for it yet?

Hi Amaan, I was able to make my own solution, which unfortunately didn't use a placeholder, but is ultimately a better option. I ended up using selenium to create a web browser, then have the user log in, and once the user was logged in, I saved the cookies to a Netscape HTTP Cookies File format, and using those cookies to authenticate has worked fine.

0 votes
Andy Gladstone Community Leader Jul 27, 2022

@Matthew Kennedy welcome to the Atlassian Community.

This seems to be a question about Confluence rather than a question related to the add-on Questions for Confluence. I am moving this to the Confluence collection to get more eyes on this and hopefully an answer for you.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events