The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to supply authentication with Python for Confluence Cloud API

Vincent Stevenson
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 2, 2019

How do I include my apikey and username when I am using Confluence API? 

Here's my code: 

import requests
import json

url = "https://example.atlassian.net/wiki/rest/api/audit"

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Where would I add the authentication?

Thanks!

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2019

Hi @Vincent Stevenson ,

Welcome to the Atlassian Community.

This question has already been asked many times and by searching the community you can find threads having examples showing how to do so like, for example, the below one:

 

Please review above thread and let us know if it helps.

 

Cheers,
Dario

Emilio Sebastian Carranza
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 21, 2020

Hi Dario, the thread you are referencing is about Jira. Do you know if there is a similar solution to use with Confluence?

Thanks!

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2020

Hi @Emilio Sebastian Carranza ,

Please notice that basic authentication with Atlassian Account (email address) and API Token works exactly the same way in Jira Cloud and Confluence Cloud. Therefore, the already provided example works for both.

For details:

 

Ciao,
Dario

Emilio Sebastian Carranza
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, 2020

Thanks, I got it now. 

Like Dario B likes this