Json call doesnt see admin right

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Json call doesnt see admin right

Post by desertdog »

I want to change switches via a API call, so first of all I tested if I can connect to Domiticz with:

https://USERNAME:[email protected]:4 ... getversion and also tried the variant where USERNAME and PASSWORD are base64 encoded. In both cases I get this result:
{
"HaveUpdate" : false,
"UseUpdate" : false,
"build_time" : "2023-02-14 15:06:40",
"dzvents_version" : "3.1.8",
"hash" : "f9b9ac774",
"python_version" : "3.7.3 (default, Jan 22 2021, 20:04:44) \n[GCC 8.3.0]",
"status" : "OK",
"title" : "GetVersion",
"version" : "2023.1"
}
According to the documentation: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's, this is the result: When requested by a (non-admin) User (which is the current default response for users)
But the username and password I use are those from an admin, I also tried adding a new admin and tried with these credentials, but this gives the same result. WhenI i try other json parameters I get the Unauthorized page. So something seems the go wrong.

What is the correct way to connect?
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Json call doesnt see admin right

Post by waltervl »

The different versions of result from getversion JSON call is implemented in current 2023.1 beta. You are using 2023.1 stable.

Perhaps use another JSON call.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Json call doesnt see admin right

Post by kiddigital »

How are you testing the API call? Some browser drop the Username:password part before sending the request for safety reasons.

Maybe use a tool like Postman to test your API call so you can be sure that the request and responses are ok and readable for you as well.

API calls can currently still be made by sending an 'Authorization'-header with base64 encoded 'Basic' authentication (see Wiki).

Better would be to start using the OAuth2/OpenID connect methods ('password' grant-type or even better the 'authorization_code' grant type (with PKCE)), see the SECURITY_SETUP.md for more details.

If you enable the 'webserver,recevied,auth' debug flags (start domoticz with --debugflags ..), you can see what domoticz is receiving and what happens during authentication.

Hope the above helps.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Json call doesnt see admin right

Post by kiddigital »

waltervl wrote: Friday 21 July 2023 21:20 The different versions of result from getversion JSON call is implemented in current 2023.1 beta. You are using 2023.1 stable.

Perhaps use another JSON call.
And now in 2023.2 Stable as well! :D
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: Json call doesnt see admin right

Post by desertdog »

I updated to the latest version, running the same url now results in chrome browser

Code: Select all

{
	"status" : "OK",
	"title" : "GetVersion"
}
when I try to post the same URL in Postman I get 'could not send request', but I don't know Postman that well, so not really sure what's happening there. Also tried them with a curl command (curl full URL), but also nothing there

I need single URLs that have to be pasted into the backend of a supplier's hardware device. so with one url call, I need to update a switch in Domoticz when the hardware device changes. Are there any people that can get a working reponse when they try this on their Domoticz installation? I mean: is this broken in Domoticz maybe?
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Json call doesnt see admin right

Post by kiddigital »

Did you enable the mentioned debug flags?

The result shows (as you are now using 2023.2) that domoticz does either not see the credentials or the credentials are not accepted. The debug information will tell you which one it is.

What curl command did you use? I would expect curl to work fine as well.

The URL is an HTTPS url and not plain HTTP? If so, although not advisable especially when called by some external device, you need to enable Basic-Auth over HTTP first.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest