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
Community Members
Community Events
Community Groups

Using atlassian python confluence with microsoft authenticated account?

I am an experienced python coder and want to access Confluence via Python.  I wrote a simple 2 line script to test that I had access and found that I had not

from atlassian import Confluence

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

I get the result:

HTTPError: 401 Client Error: Unauthorized for url:

I am using the correct username and password but they are my Microsoft credentials; I do not have a direct confluence account.

Is there a different authentication method for users who use Microsoft Authenticated accounts? 

1 answer

1 accepted

2 votes
Answer accepted
Thomas Deiler Community Leader May 08, 2021

Dear @Stephen Ellwood ,

that won't work. Basic auth is not allowed anymore for cloud. You need to take the Api token for the 'password', instead.


You can generate your own Api token here:

So long


Thanks, I was confused by the use of the name password instead of the name token. Working now!

Thomas Deiler Community Leader May 10, 2021

Dear @Stephen Ellwood ,

'user' and 'password' are just variable names in your Python function Confluence(). You could rename them to 'email' and 'token'. The effect will be the same.

So long


Hi @Thomas Deiler understood that "user" and "password" are [optional] parameter names for the Confluence Class instance creator.  Several instance methods are described some using the parameter "password" and others using the parameter "token". 

While I completely agree with "that which we call a Rose by any other name would smell as sweet" and am in no way wanting to sound defensive but in this case I saw "token" and "password" not used interchangeably so did not think to do so. 

Thanks again for your help. Pleased it was so easy to solve.

I am having a similar error:

401 Client Error:  for url

Initially, I generated a conflucene token from here ( and used that for the password.

Then, I tried following the solution above by generating an Atlassian token and passing it in for the password, but I am still getting this error.

However, my error statement does not say "Unauthorized".

If I try to provide a wrong password, I also get the same error message.

@Thomas Deiler Your help is much appreciated.

Thomas Deiler Community Leader Sep 16, 2022

Dear @Kamal Ali ,

do you user Confluence Cloud or Server? For Cloud the request looks like this:

for more details:

So long


Suggest an answer

Log in or Sign up to answer

Atlassian Community Events