lucasheld / uptime-kuma-api

A Python wrapper for the Uptime Kuma Socket.IO API
https://uptime-kuma-api.readthedocs.io
MIT License
273 stars 23 forks source link

Turn off authentication via API #5

Closed openstep closed 2 years ago

openstep commented 2 years ago

Hi again,

Is there an API to turn on / off authentication on Uptime Kuma? Ie. there is a new kuma app running and so far no username / pass set. Can I call an API to turn off authentication?

lucasheld commented 2 years ago

Yes, there is a method set_settings.

To disable authentication, you have to submit the current password and set disableAuth to True. This also means that you need to setup a username and password beforehand, then login and disable authentication.

from uptime_kuma_api import UptimeKumaApi

username = "admin"
password = "secret123"

api = UptimeKumaApi("http://127.0.0.1:3001")
api.setup(username, password)
api.login(username, password)
api.set_settings(password=password, disableAuth=True)
api.disconnect()

To re-enable authentication, the password is not required.

api.set_settings(disableAuth=False)
openstep commented 2 years ago

Many thanks for the prompt answer.