Forums

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

Atlassian API Token doesn't work in python script but it works in curl

Petar Dimovski
October 27, 2021

Hello Everyone, 

I created an access token in the atlassian web application and it works when I use curl like this:

curl --user "petar.dimovski@etxcapital.com:TOKEN https://etxcapital.atlassian.net/wiki/rest/api/content&type=page

but when I ping the api from a python script I get the following response:

{"message":"Current user not permitted to use Confluence","statusCode":403}

What should I do in order to make it work like curl does?

Here's the python script:

import os
import requests
from requests.auth import HTTPBasicAuth

confluence_api_url ="https://etxcapital.atlassian.net/wiki/rest/api"

def get_auth_details():
return HTTPBasicAuth(os.getenv("username"), os.getenv('token'))


def get_pages(label=None):
params = {
'type':'page',
# 'start':0,
# 'limit':500
}
if label:
params["label"] = label

resp = requests.get(f"{confluence_api_url}/content/search.json",
auth=get_auth_details(),
params=params)

return resp.json()

 

0 answers

Suggest an answer

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

Atlassian Community Events