External JSON API Issue Topic is solved
Moderators: leecollings, remb0
-
- Posts: 11
- Joined: Tuesday 27 September 2016 14:22
- Target OS: Windows
- Domoticz version:
- Contact:
External JSON API Issue
I'm trying to update a Lux value from outside my network using
http://USERNAME:[email protected] ... &svalue=99
The dummy virtual ID is correct and if I try internally with the local IP address rather than MYDDNSHOST.ddns.net it works, but I keep getting
401 Unauthorized
What's going wrong? Do I need to turn on external access somewhere? Ports are opened and forwarded on my router.
Cheers
Gary
http://USERNAME:[email protected] ... &svalue=99
The dummy virtual ID is correct and if I try internally with the local IP address rather than MYDDNSHOST.ddns.net it works, but I keep getting
401 Unauthorized
What's going wrong? Do I need to turn on external access somewhere? Ports are opened and forwarded on my router.
Cheers
Gary
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: External JSON API Issue
Sorry to say, security (however very basic) is preventing your action.
I suggest you read other posts to get your security at an even higher level, or get your whishes in line. Then you will understand why its working by ipaddress on the intranet/local network and not from the internet.
I suggest you read other posts to get your security at an even higher level, or get your whishes in line. Then you will understand why its working by ipaddress on the intranet/local network and not from the internet.
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: External JSON API Issue
Very cryptic reply. I run into the same issue and have posted a couple times in another thread about this subject. I unfortunately never received an answer on them. I also would like to turn on the light at the front door through Tasker when my phone disconnects from my car Bluetooth at the moment that I arrive at home.
-
- Posts: 11
- Joined: Tuesday 27 September 2016 14:22
- Target OS: Windows
- Domoticz version:
- Contact:
Re: External JSON API Issue
I agree - cryptic reply!
It must be Domoticz providing the 401 error as there are no other web servers on port 8080, and there wouldn't be a timeout rather than a reply if it hadn't reached a server.
It must be Domoticz providing the 401 error as there are no other web servers on port 8080, and there wouldn't be a timeout rather than a reply if it hadn't reached a server.
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: External JSON API Issue
Sorry guys, but these questions in some simular cases, are reoccuring.
Again, not so cryptic.
- Read the manual (settings/system setup/half way !)
- Check wiki's about remote access (eg vpn/nginx)
- search the forum (prefer browser as eg. tapatalk doesnt work well)
I mentioned security because the way you made Domoticz available with portforwards in your router. It is not what you want! Basically said: leave your house and let the frontdoor wide open.
Again, not so cryptic.
- Read the manual (settings/system setup/half way !)
- Check wiki's about remote access (eg vpn/nginx)
- search the forum (prefer browser as eg. tapatalk doesnt work well)
I mentioned security because the way you made Domoticz available with portforwards in your router. It is not what you want! Basically said: leave your house and let the frontdoor wide open.
-
- Posts: 11
- Joined: Tuesday 27 September 2016 14:22
- Target OS: Windows
- Domoticz version:
- Contact:
Re: External JSON API Issue
Ok.....
"Read the manual (settings/system setup/half way!)"
I have done but was asking for assistance as it doesn't seem to be doing what it says it should be doing. The documentation is good but the whole point of forums is to help clarify things.
"Check wiki's about remote access (eg vpn/nginx)"
Would you be kind enough to point me in the right direction for that?
"I mentioned security because the way you made Domoticz available with portforwards in your router. It is not what you want!"
Appreciate the concerns about security, but I just want to get it working first then I will tie the security down - with loads of security on to start with it's difficult to ascertain why it isn't working.
"Read the manual (settings/system setup/half way!)"
I have done but was asking for assistance as it doesn't seem to be doing what it says it should be doing. The documentation is good but the whole point of forums is to help clarify things.
"Check wiki's about remote access (eg vpn/nginx)"
Would you be kind enough to point me in the right direction for that?
"I mentioned security because the way you made Domoticz available with portforwards in your router. It is not what you want!"
Appreciate the concerns about security, but I just want to get it working first then I will tie the security down - with loads of security on to start with it's difficult to ascertain why it isn't working.
- robpow
- Posts: 38
- Joined: Friday 19 July 2013 19:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta :)
- Location: .se
- Contact:
Re: External JSON API Issue
Check if you have forms-based authentication enabled instead of basic auth in Domoticz settings.
Or you could send a basic auth header as described here:
https://www.domoticz.com/wiki/Domoticz_ ... horization
Matt
Or you could send a basic auth header as described here:
https://www.domoticz.com/wiki/Domoticz_ ... horization
Matt
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: External JSON API Issue
[quote=quiggles]
As basic start:
[/quote]
localhost adress 127.0.0.1 is filled in so locally theres no authentication, expand this with your default intranet network mostly 192.168.0.*.
Then other then that MUST authenticate. Basic Authentication is done with proper header (see formentioned wiki about JSON)
Or formbased login, presents you a webpage (you dont want that with JSON requests)
When you setup {open}VPN also enables you to include that range as a private network, so authentication isn't needed. Google for OpenVPN raspbian will get you up and running in 30minutes!
Secure remote access with nginx is halfway mostright colom on domoticz.com/wiki/
As basic start:
[/quote]
localhost adress 127.0.0.1 is filled in so locally theres no authentication, expand this with your default intranet network mostly 192.168.0.*.
Then other then that MUST authenticate. Basic Authentication is done with proper header (see formentioned wiki about JSON)
Or formbased login, presents you a webpage (you dont want that with JSON requests)
When you setup {open}VPN also enables you to include that range as a private network, so authentication isn't needed. Google for OpenVPN raspbian will get you up and running in 30minutes!
Secure remote access with nginx is halfway mostright colom on domoticz.com/wiki/
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: External JSON API Issue
And security starts with everything closed, and open whats relay necessary, even Microsofts firewall starts this way. It makes you think in advance instead of look surprised when you forget to close that one hole.
Yes i'm a SysAdmin, and i'm stunned by fellow workers who start open and THEY DO forget about that 1 hole. And i have seen Corperate Networks go down in seconds because of that 1 hole.
Yes i'm a SysAdmin, and i'm stunned by fellow workers who start open and THEY DO forget about that 1 hole. And i have seen Corperate Networks go down in seconds because of that 1 hole.
-
- Posts: 14
- Joined: Thursday 31 December 2015 23:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: External JSON API Issue
I am having a similar issue due to allow-origin errors. Trying to pull in domoticz data into another application. Failing miserably.
-
- Posts: 11
- Joined: Tuesday 27 September 2016 14:22
- Target OS: Windows
- Domoticz version:
- Contact:
Re: External JSON API Issue
Aha RobPow nailed it...
Don't I feel dumb now!
However I shall take on the advice about security as well!
As soon as I changed to basic auth it started working - thanks!Check if you have forms-based authentication enabled instead of basic auth in Domoticz settings.
Don't I feel dumb now!


However I shall take on the advice about security as well!

-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: RE: Re: External JSON API Issue
Don't feel dump... Glad you looked again and got it working.quiggles wrote:Aha RobPow nailed it...
As soon as I changed to basic auth it started working - thanks!Check if you have forms-based authentication enabled instead of basic auth in Domoticz settings.
Don't I feel dumb now!![]()
![]()
However I shall take on the advice about security as well!
Sometimes (thats why i mentioned read the manual and wiki


Re: External JSON API Issue
I have DomoticZ behind nginx reverse proxy that provide HTTPS. Is in this case safe to use the login form and so to call the API like this: HTTPS://example.com/json.htm?username=M ... tchcmd=Offstlaha2007 wrote: ↑Sunday 20 November 2016 19:25 Sorry to say, security (however very basic) is preventing your action.
If yes, how do I bypass the 401 Unauthorized?
Thanks!
-
- Posts: 370
- Joined: Monday 05 October 2015 10:16
- Target OS: -
- Domoticz version:
- Contact:
Re: External JSON API Issue
In short: Depends. As long as the form with user and pass are encrypted for external access, it can be save.
Encryption depends on your certificates, so that must be setup really good.
Ask yourself, must others have the access to your home other then yourself. If yes, please expose Domoticz. If not, use an VPN.
For myself, i don't expose my Domoticz to the outside, as it eventually invites hackers to control your house
To look it wpuld be save to setup with users within Domoticz with Look permissions or with a small set of switches they should be able to access and control.
I use a VPN with password and certificates to access my internal network, and then i also need to login to domoticz and other devices. In short multi-level security.
Encryption depends on your certificates, so that must be setup really good.
Ask yourself, must others have the access to your home other then yourself. If yes, please expose Domoticz. If not, use an VPN.
For myself, i don't expose my Domoticz to the outside, as it eventually invites hackers to control your house

I use a VPN with password and certificates to access my internal network, and then i also need to login to domoticz and other devices. In short multi-level security.
- philchillbill
- Posts: 399
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: External JSON API Issue
@andrex
in the json you don't put username=xxx:password=yyy in the URL, just the xxx:yyy without the keywords username and password. That's why you're getitng unauthorized because it thinks your're logging in to basic auth with a username of "username=xxx" and a password of "password=yyy". And they are not your username and password
in the json you don't put username=xxx:password=yyy in the URL, just the xxx:yyy without the keywords username and password. That's why you're getitng unauthorized because it thinks your're logging in to basic auth with a username of "username=xxx" and a password of "password=yyy". And they are not your username and password

Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Re: External JSON API Issue
Sorry for the very late reply, but I forgot to thank you!philchillbill wrote: ↑Saturday 30 March 2019 22:47 @andrex
in the json you don't put username=xxx:password=yyy in the URL, just the xxx:yyy without the keywords username and password. That's why you're getitng unauthorized because it thinks your're logging in to basic auth with a username of "username=xxx" and a password of "password=yyy". And they are not your username and password![]()
Who is online
Users browsing this forum: No registered users and 1 guest