atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

401 with scoped access token

Open lobeck opened this issue 5 months ago • 3 comments

I have created a scoped PAT with scopes:

read:page:confluence
write:page:confluence

Due to #1199, the client is then initiated as follows:

confluence = Confluence(
    url=CONFLUENCE_BASE_URL,
    username=CONFLUENCE_USER,
    password=CONFLUENCE_API_TOKEN,
    cloud=True
)

Now when doing a call like

page = confluence.get_page_by_id(CONFLUENCE_PAGE_ID)

It results in a requests.exceptions.HTTPError: Unauthorized (401)

It works when using an unscoped access token. This is version 4.0.4.

lobeck avatar Jun 16 '25 12:06 lobeck

curious if you were able to find a workaround for this, apart from using an unscoped access token?

dddlr avatar Jun 18 '25 05:06 dddlr

No, I have't tested further. I'm waiting on some clarifying comments from Atlassian. Also on the other library issues.

lobeck avatar Jun 18 '25 10:06 lobeck

All good, I think atlassian-python-api is an unofficial repo unrelated to atlassian, and i don't have any domain knowledge on confluence REST APIs 😅 hopefully @gonchik has capacity to look into it

dddlr avatar Jun 19 '25 00:06 dddlr

According to the information provided on this page, the endpoint changes when using a scoped token.

I was able to access it with the following setting:

CONFLUENCE_BASE_URL=https://api.atlassian.com/ex/confluence/{cloudid}

We are able to find the cloudid at https://{your-domain}.atlassian.net/_edge/tenant_info.

hajimegane avatar Jun 26 '25 04:06 hajimegane

@dddlr you're right, this project is unofficial, but only mentions it in the fine print. From the appearance it seemed official :(

@hajimegane Thank you for the hint. This got it working, but the API Documentation is incomplete, so it's a guesswork to find the right scopes. Created several tickets with Atlassian, so they improve their documentation.

lobeck avatar Jun 27 '25 14:06 lobeck

@lobeck did you get it working with the scope? Can you please provide a small working example? Thanks

ksaurabhAparavi avatar Jul 18 '25 17:07 ksaurabhAparavi

@ksaurabhAparavi no. I also asked Atlassian support about it and they noted, that scopes only work with the v2 API which is not implemented in this library yet.

lobeck avatar Jul 18 '25 22:07 lobeck