I searched for how to send requests to OH3 with API tokens in Jython/Python and found this thread, but no immediate answer on how to do it in Python.
It’s quite easy to deduct it from how @ariela ist doing it in JS.
Nevertheless here is an example, as it might be helpful for someone else:
from core.actions import HTTP
api_token = "oh.name.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
auth_headers = {
"Authorization": "Bearer {}".format(api_token),
"WWW-Authenticate": "Basic",
}
HTTP.sendHttpPutRequest(
"http://my-oh.local/rest/things/max:bridge:IEQ0547745/config", # your OH domain & path in the REST-API
"application/json",
"{action-cubeReboot:1234}",
auth_headers, # here is where the auth-info is handed over to the HTTP action
9000) # a timeout value
Basic Auth is turned on, but the Alexa skill integrates using OAUTH, so I figured i just needed a matching username on OH3 (same as the OH3 Cloud or the Alexa skill) - still no joy
jwiseman
(Mr. Wiseman (OH 4.2 Snapshot on Pi4))
23
I’m having trouble getting this to work with OH 3.2. I have the same code above but it’s NOT re-enabling a few THINGs that are disabled. Am I missing something?