# Confluence REST API Configuration
confluence_url = 'http://localhost:8888/rest/api'
confluence_token = 'token'
headers = {'Authorization': f'Bearer {confluence_token}'}
...
...
try:
# Execute the SQL query
cursor = connection.cursor()
cursor.execute(sql_query)
# Fetch the result
users = cursor.fetchall()
# Loop through users and print them out
for user, last_login in users:
print(f"User: {user}, last login: {last_login}")
# API endpoint to disable a user
disable_user_url = f"{confluence_url}/admin/user/{user}/disable"
# Making a PUT request to disable the user
response = requests.put(disable_user_url, headers=headers)
# Printing the response
print(f"Response: {response.status_code}, {response.text}")
finally:
# Close the connection
connection.close()
Ignore the indentation. The error I get is:
Response: 401, <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>401</status-code><message>This resource requires WebSudo.</message></status>
Also ignore the localhost part, I'm port forwarding.
I don't understand what I need to do. I want to automate this process and run it as a cron job.
Edit because I can't comment for some reason:
I managed to get around Websudo by using my username and password with basic authentication, just had to use secrets 
Thanks!