Atlassian Confluence REST API Error: Current user not permitted to use Confluence

233 views Asked by At

I'm trying to update a page on Confluence using a Python script but I'm getting this error:

Traceback (most recent call last):
  File "/Users/Abdullah.Khawer/Desktop/find-secrets-in-code-to-alert-on-slack-and-track-on-confluence/main.py", line 76, in <module>
    page_id = conf.get_page_id(page_space, page_title)
  File "/opt/homebrew/lib/python3.10/site-packages/atlassian/confluence.py", line 220, in get_page_id
    return (self.get_page_by_title(space, title, type=type) or {}).get("id")
  File "/opt/homebrew/lib/python3.10/site-packages/atlassian/confluence.py", line 305, in get_page_by_title
    response = self.get(url, params=params)
  File "/opt/homebrew/lib/python3.10/site-packages/atlassian/rest_client.py", line 288, in get
    response = self.request(
  File "/opt/homebrew/lib/python3.10/site-packages/atlassian/rest_client.py", line 260, in request
    self.raise_for_status(response)
  File "/opt/homebrew/lib/python3.10/site-packages/atlassian/confluence.py", line 3245, in raise_for_status
    raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError: Current user not permitted to use Confluence

My Python script looks as follows:

from atlassian import Confluence

conf_site = os.getenv("CONFLUENCE_SITE")
conf_user = os.getenv("CONFLUENCE_USER_EMAIL_ID")
conf_pass = os.getenv("CONFLUENCE_USER_TOKEN")

conf = Confluence(url=conf_site, username=conf_user, password=conf_pass)

Python script reference: GitHub > abdullahkhawer > find-secrets-in-code-to-alert-on-slack-and-track-on-confluence > main.py

How to fix this? The username and password for the user I used are correct. The user is a service account.

1

There are 1 answers

1
Abdullah Khawer On BEST ANSWER

To make it work, I had to do all of the following on the Atlassian user (which is a service account in my case):

  • Give access to the Confluence app.
  • Give the View and Add permissions in the desired space.
  • Give the Can edit permission on the page in that space.
  • Create an API token and use it instead of password.