Closed Astroman closed 8 years ago
Taken from #2 ::
Fauxmo 0.1.11 Python 3.5.1 MacOS 10.10.5 Yosemite
I'm not sure I understand what your URL looks like. Do you have an example request / command that works with either curl
or requests? Or just an example of the kind of URL you're using?
For Indigo with authentication on the local server, here are two types of URLs: http://user:pass@localhost/indigo/devices/Hall%20Light?isOn=1&_method=put https://user:pass@localhost/indigo/actions/Lock The Door?_method=execute
Note that the low level handshaking works as a redirect. The server returns a URL to send the client to and the authentication must carry over to the second call. Apparently this is a common mechanism and browsers handle it fine.
For Home Remote, the URL is a little simpler, and I don't think the redirects are used, but still does not work with FauxMo: http://user:pass@localhost:9090/?action=Stop%20House%20Fan In all cases, I can issue the URLs from a browser and they work.
It's been quite a while since I constructed the Indigo URLs with curl but I was able to do it. It would take some digging to remind myself when I did this and find it.
Can you try something?
First, get the bytestring returned by:
import base64
print(base64.encodebytes("{}:{}".format("user","pass").encode('ascii')))
You may need to strip the trailing \n
, if any.
Then, try to make a device with:
You may need to play with bytes vs strings. Idea taken from here, may not work. Note the space after Basic
.
You can test this manual attempt at HTTP Basic Auth with httpbin at the /basic-auth/:user/:passwd
endpoint, where you replace :user
and :passwd
with whatever (fake) credentials you want, and you send the Authorization: Basic asdf
header as per above (where asdf
is the base64.encodebytes
of user:passwd
).
If your auth worked, it responds with JSON including "authenticated": true
.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii'))
Out[6]: b'dXNlcjpwYXNzd2Q=\n'
...
In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text
Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n'
In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n'
In [16]: requests.get("https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text
Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n'
You should be able to get the string you need to put after Basic
with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip()
(replacing this
and that
with your user and passwd respectively).
Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests
import base64
def return_basic_auth(user,passwd):
inbytes = '{}:{}'.format(user, passwd).encode('ascii')
outbytes = base64.encodebytes(inbytes)
outstr = outbytes.decode('ascii').strip()
return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content
Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
I'll give it a try but it may be a few days before I can get to it. Thanks.
--Dave
On Feb 21, 2016, at 5:53 AM, Nathan Henrie notifications@github.com wrote:
You can test this manual attempt at HTTP Basic Auth with httpbin at the /basic-auth/:user/:passwd endpoint, where you replace :user and :passwd with whatever (fake) credentials you want, and you send the Authorization: Basic asdf header as per above (where asdf is the base64.encodebytes of user:passwd).
If your auth worked, it responds with JSON including "authenticated": true.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii')) Out[6]: b'dXNlcjpwYXNzd2Q=\n' ... In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n' In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n' In [16]: requests.get("https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n' You should be able to get the string you need to put after Basic with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip() (replacing this and that with your user and passwd respectively).Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests import base64
def return_basic_auth(user,passwd): inbytes = '{}:{}'.format(user, passwd).encode('ascii') outbytes = base64.encodebytes(inbytes) outstr = outbytes.decode('ascii').strip() return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
— Reply to this email directly or view it on GitHub.
I actually found some time to try it. I think the httpbin test passed, returning b'{\n "authenticated": true, \n "user": "fakeuser"\n}\n'
However I get a syntax error when I try
requests.get("http://localhost:9090/?action=Toggle%20Christmas%20Tree", headers=return_basic_auth("user", "pass")).content)
Is this the right wasy to frame the request?
—Dave
On Feb 21, 2016, at 5:53 AM, Nathan Henrie notifications@github.com wrote:
You can test this manual attempt at HTTP Basic Auth with httpbin https://httpbin.org/ at the /basic-auth/:user/:passwd endpoint, where you replace :user and :passwd with whatever (fake) credentials you want, and you send the Authorization: Basic asdf header as per above (where asdf is the base64.encodebytes of user:passwd).
If your auth worked, it responds with JSON including "authenticated": true.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii')) Out[6]: b'dXNlcjpwYXNzd2Q=\n' ... In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n' In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n' In [16]: requests.get("https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n' You should be able to get the string you need to put after Basic with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip() (replacing this and that with your user and passwd respectively).Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests import base64
def return_basic_auth(user,passwd): inbytes = '{}:{}'.format(user, passwd).encode('ascii') outbytes = base64.encodebytes(inbytes) outstr = outbytes.decode('ascii').strip() return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-186827023.
Whoops. Extra paren. Gives error about content but I’ll keep trying.
On Feb 21, 2016, at 10:28 AM, Dave Leiner dave@theleiners.com wrote:
I actually found some time to try it. I think the httpbin test passed, returning b'{\n "authenticated": true, \n "user": "fakeuser"\n}\n'
However I get a syntax error when I try
requests.get("http://localhost:9090/?action=Toggle%20Christmas%20Tree http://localhost:9090/?action=Toggle%20Christmas%20Tree", headers=return_basic_auth("user", "pass")).content)
Is this the right wasy to frame the request?
—Dave
On Feb 21, 2016, at 5:53 AM, Nathan Henrie <notifications@github.com mailto:notifications@github.com> wrote:
You can test this manual attempt at HTTP Basic Auth with httpbin https://httpbin.org/ at the /basic-auth/:user/:passwd endpoint, where you replace :user and :passwd with whatever (fake) credentials you want, and you send the Authorization: Basic asdf header as per above (where asdf is the base64.encodebytes of user:passwd).
If your auth worked, it responds with JSON including "authenticated": true.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii')) Out[6]: b'dXNlcjpwYXNzd2Q=\n' ... In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n' In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n' In [16]: requests.get("https://httpbin.org/basic-auth/this/that https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n' You should be able to get the string you need to put after Basic with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip() (replacing this and that with your user and passwd respectively).Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests import base64
def return_basic_auth(user,passwd): inbytes = '{}:{}'.format(user, passwd).encode('ascii') outbytes = base64.encodebytes(inbytes) outstr = outbytes.decode('ascii').strip() return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-186827023.
By deleting the content parameter, I got it working without securing the server. But it does not pass authentication. I’ll keep trying but any suggestions would be helpful.
On Feb 21, 2016, at 10:32 AM, Dave Leiner dave@theleiners.com wrote:
Whoops. Extra paren. Gives error about content but I’ll keep trying.
On Feb 21, 2016, at 10:28 AM, Dave Leiner <dave@theleiners.com mailto:dave@theleiners.com> wrote:
I actually found some time to try it. I think the httpbin test passed, returning b'{\n "authenticated": true, \n "user": "fakeuser"\n}\n'
However I get a syntax error when I try
requests.get("http://localhost:9090/?action=Toggle%20Christmas%20Tree http://localhost:9090/?action=Toggle%20Christmas%20Tree", headers=return_basic_auth("user", "pass")).content)
Is this the right wasy to frame the request?
—Dave
On Feb 21, 2016, at 5:53 AM, Nathan Henrie <notifications@github.com mailto:notifications@github.com> wrote:
You can test this manual attempt at HTTP Basic Auth with httpbin https://httpbin.org/ at the /basic-auth/:user/:passwd endpoint, where you replace :user and :passwd with whatever (fake) credentials you want, and you send the Authorization: Basic asdf header as per above (where asdf is the base64.encodebytes of user:passwd).
If your auth worked, it responds with JSON including "authenticated": true.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii')) Out[6]: b'dXNlcjpwYXNzd2Q=\n' ... In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n' In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n' In [16]: requests.get("https://httpbin.org/basic-auth/this/that https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n' You should be able to get the string you need to put after Basic with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip() (replacing this and that with your user and passwd respectively).Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests import base64
def return_basic_auth(user,passwd): inbytes = '{}:{}'.format(user, passwd).encode('ascii') outbytes = base64.encodebytes(inbytes) outstr = outbytes.decode('ascii').strip() return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-186827023.
I got the function working so the URL hit my Indigo server but access was denied so authentication was not being passed correctly.
—Dave
On Feb 21, 2016, at 10:35 AM, Dave Leiner dave@theleiners.com wrote:
By deleting the content parameter, I got it working without securing the server. But it does not pass authentication. I’ll keep trying but any suggestions would be helpful.
On Feb 21, 2016, at 10:32 AM, Dave Leiner <dave@theleiners.com mailto:dave@theleiners.com> wrote:
Whoops. Extra paren. Gives error about content but I’ll keep trying.
On Feb 21, 2016, at 10:28 AM, Dave Leiner <dave@theleiners.com mailto:dave@theleiners.com> wrote:
I actually found some time to try it. I think the httpbin test passed, returning b'{\n "authenticated": true, \n "user": "fakeuser"\n}\n'
However I get a syntax error when I try
requests.get("http://localhost:9090/?action=Toggle%20Christmas%20Tree http://localhost:9090/?action=Toggle%20Christmas%20Tree", headers=return_basic_auth("user", "pass")).content)
Is this the right wasy to frame the request?
—Dave
On Feb 21, 2016, at 5:53 AM, Nathan Henrie <notifications@github.com mailto:notifications@github.com> wrote:
You can test this manual attempt at HTTP Basic Auth with httpbin https://httpbin.org/ at the /basic-auth/:user/:passwd endpoint, where you replace :user and :passwd with whatever (fake) credentials you want, and you send the Authorization: Basic asdf header as per above (where asdf is the base64.encodebytes of user:passwd).
If your auth worked, it responds with JSON including "authenticated": true.
For example:
In [6]: base64.encodebytes('{}:{}'.format("user", "passwd").encode('ascii')) Out[6]: b'dXNlcjpwYXNzd2Q=\n' ... In [13]: requests.get("https://httpbin.org/basic-auth/user/passwd https://httpbin.org/basic-auth/user/passwd", headers={"Authorization": b"Basic dXNlcjpwYXNzd2Q="}).text Out[13]: '{\n "authenticated": true, \n "user": "user"\n}\n' In [15]: base64.encodebytes('{}:{}'.format("this", "that").encode('ascii'))
Out[15]: b'dGhpczp0aGF0\n' In [16]: requests.get("https://httpbin.org/basic-auth/this/that https://httpbin.org/basic-auth/this/that", headers={"Authorization": b"Basic dGhpczp0aGF0"}).text Out[16]: '{\n "authenticated": true, \n "user": "this"\n}\n' You should be able to get the string you need to put after Basic with base64.encodebytes('{}:{}'.format("this", "that").encode('ascii')).decode('ascii').strip() (replacing this and that with your user and passwd respectively).Alternatively, here's a little function that you can pass your credentials to and it will return your headers as a dictionary -- likely even easier for httpbin testing.
import requests import base64
def return_basic_auth(user,passwd): inbytes = '{}:{}'.format(user, passwd).encode('ascii') outbytes = base64.encodebytes(inbytes) outstr = outbytes.decode('ascii').strip() return {"Authorization": "Basic {}".format(outstr)}
requests.get("https://httpbin.org/basic-auth/fakeuser/fakepasswd https://httpbin.org/basic-auth/fakeuser/fakepasswd", headers=return_basic_auth("fakeuser", "fakepasswd")).content Once you have this working with httpbin, can you try to experiment with your indigo setup? If it works without too much trouble it may be worth me including a similar helper function in Fauxmo. If it doesn't work, we'll have to take a closer look at the issue -- maybe it's not the HTTP Basic Auth at all.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-186827023.
Hmmm. I want to make sure we're talking about the same thing.
Is there a chance you could temporarily change your Indigo credentials so that we could see the exact URL you're using in your Fauxmo config?
Regardless, perhaps we can do some testing with curl
again to see where the problem lies. So with httpbin, this should work:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic $(printf 'this:that' | base64)"
You can also take the value of printf 'this:that' | base64
and use it to replace the value above to show that this works:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic dGhpczp0aGF0"`
I want you to try this same method using curl
to see if you can get your Indigo URLs to work, which will make sure the auth is working properly.
For example, replace user:pass
with your Indigo values and run:
curl http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put -H "Authorization: Basic $(printf 'user:pass' | base64)"
If that works, then do printf 'user:pass' | base64
, and replace that value in the curl
command to make sure it works.
If you can verify that works, I think we should be able to get Fauxmo running for you. If you can't get that to work, then I may be barking up the wrong tree in terms of where the problem lies.
EDIT: Also, is it the same device running Fauxmo that is running the Indigo server? Otherwise the localhost
may need to be replaced by an actual IP address
A typical URL I would issue to, say, execute the action “Test” would look like this:
https://user:pass@localhost/indigo/actions/Test?_method=execute
My actual username and password would be substituted for “user" and “pass” of course. For device on/off commands, the URL would look a little difference but this example would be a little easier for our tests.
The address could be localhost, or a LAN or WAN address depending on where it is being called from. In the case of FauxMo, I would use localhost.
I’ll try the other tests when I get a chance over the next couple of days.
Thanks. —Dave
On Feb 22, 2016, at 7:57 AM, Nathan Henrie notifications@github.com wrote:
Hmmm. I want to make sure we're talking about the same thing.
Is there a chance you could temporarily change your Indigo credentials so that we could see the exact URL you're using in your Fauxmo config?
Regardless, perhaps we can do some testing with curl again to see where the problem lies. So with httpbin, this should work:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic $(printf 'this:that' | base64)" You can also take the value of printf 'this:that' | base64 and use it to replace the value above to show that this works:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic dGhpczp0aGF0"` I want you to try this same method using curl to see if you can get the URLs to work, which will make sure the auth is working properly.
For example, replace user:pass with your Indigo values and run:
curl http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put -H "Authorization: Basic $(printf 'user:pass' | base64)" If that works, then do printf 'user:pass' | base64, and replace that value in the curl command to make sure it works.
If you can verify that works, I think we should be able to get Fauxmo running for you. If you can't get that to work, then I may be barking up the wrong tree in terms of where the problem lies.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-187243171.
Fair enough. Let me know when you get the curl
command to work -- that should help us figure out the necessary changes.
Based on this overview of Indigo URL scheme, I'm thinking the necessary config may end up being something like:
{
"port": 12345,
"handler": {
"on_cmd": "http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put",
"off_cmd": "http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put",
"method": "POST",
"headers": {"Authorization": "Basic asdf"}
},
"description": "fake indigo switch"
}
I may need to change it to POST the isOn=1
-- and possibly change the POST data for the OFF command...
Executing these commands from terminal, I was able to get the first httpbin test to work, returning "authenticated": true.
However, when I tried the last curl example to my Indigo server with my username and password (with and without the printf substitution, I got access denied from Indigo.
On Feb 22, 2016, at 7:57 AM, Nathan Henrie notifications@github.com wrote:
Hmmm. I want to make sure we're talking about the same thing.
Is there a chance you could temporarily change your Indigo credentials so that we could see the exact URL you're using in your Fauxmo config?
Regardless, perhaps we can do some testing with curl again to see where the problem lies. So with httpbin, this should work:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic $(printf 'this:that' | base64)" You can also take the value of printf 'this:that' | base64 and use it to replace the value above to show that this works:
curl https://httpbin.org/basic-auth/this/that -H "Authorization: Basic dGhpczp0aGF0"` I want you to try this same method using curl to see if you can get the URLs to work, which will make sure the auth is working properly.
For example, replace user:pass with your Indigo values and run:
curl http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put -H "Authorization: Basic $(printf 'user:pass' | base64)" If that works, then do printf 'user:pass' | base64, and replace that value in the curl command to make sure it works.
If you can verify that works, I think we should be able to get Fauxmo running for you. If you can't get that to work, then I may be barking up the wrong tree in terms of where the problem lies.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-187243171.
Scrolling down further on the Indigo URL Scheme webpage I linked above, it looks like it defaults to HTTP Digest authentication (not HTTP Basic Authentication, which all the above examples have been using). It can use Basic, but unless you've configured it to do so, you're probably using Digest.
Can you try this example with curl
? It should be virtually identical to what the Inidigo documentation recommends.
curl -u 'user:pass' --digest -X PUT -d 'isOn=1' http://localhost/indigo/devices/Hall%20Light
If that works, can you try again with POST
instead of PUT
?
If you're having trouble, httpbin also has an endpoint to test HTTP Digest Authentication, e.g.
curl -b /tmp/httpbin_cookie.txt -c /tmp/httpbin_cookie.txt -u 'this:that' --digest https://httpbin.org/digest-auth/auth/this/that
Again, once we get to the point of being able to interact with Indigo via curl
, I think we'll have the groundwork laid for Fauxmo.
This worked with PUT and returned a link (without credentials) to the status of the device. It did not work with POST, returning 405 Method Not Allowed.
https did not work due to an invalid certificate chain but this doesn’t matter since the requests are all internal.
I briefly tried the “action" form of the command, which uses a url like http://user:pass@localhost/indigo/devices/Test?_method=execute I wasn’t able to get it working but I wasn’t sure exactly how to form the curl request.
Good progress!
—Dave
On Feb 23, 2016, at 5:29 AM, Nathan Henrie notifications@github.com wrote:
Scrolling down further on the Indigo URL Scheme webpage I linked above, it looks like it defaults to HTTP Digest authentication (not HTTP Basic Authentication, which all the above examples have been using). It can use Basic, but unless you've configured it to do so, you're probably using Digest.
Can you try this example with curl? It should be virtually identical to what the Inidigo documentatino recommends. curl -u 'user:pass' --digest -X PUT -d 'isOn=1' http://localhost/indigo/devices/Hall%20Light
If that works, can you try again with POST instead of PUT?
If you're having trouble, httpbin also has an endpoint to test HTTP Digest Authentication, e.g. curl -b /tmp/httpbin_cookie.txt -c /tmp/httpbin_cookie.txt -u 'this:that' --digest https://httpbin.org/digest-auth/auth/this/that
Again, once we get to the point of being able to interact with Indigo via curl, I think we'll have the groundwork laid for Fauxmo.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-187699588.
Indigo actions also work with curl digest authentication using the form:
curl -u 'user:pass' --digest -X EXECUTE http://localhost/indigo/actions/Test
Just a bump to say I haven't forgotten about this. I think it should be pretty easy to implement something that works, but will take some minor changes to the code (not just the config). Hopefully within the next week. I'll need to have you test a development branch to make sure it's working, I'll let you know when it's ready.
I’ll be glad to test it when it’s ready but I wanted to let you know that I recently discovered that the Indigo developer has released a plugin that integrates Phillips Hue emulation. While it is not as general as your solution, it satisfies my needs with no technical work at all. In any event, I appreciate your help and I think that providing an authentication will help people with other types of installations.
Thanks!
—Dave
On Feb 27, 2016, at 3:10 PM, Nathan Henrie notifications@github.com wrote:
Just a bump to say I haven't forgotten about this. I think it should be pretty easy to implement something that works, but will take some minor changes to the code (not just the config). Hopefully within the next week. I'll need to have you test a development branch to make sure it's working, I'll let you know when it's ready.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-189745293.
Can you try with curl
:
curl -u 'user:pass' --digest http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put
All the examples seem to suggest that this should work, and it uses a regular GET
request.
This did not execute the device control. It just returned html with the device attributes.
On Feb 28, 2016, at 11:56 AM, Nathan Henrie notifications@github.com wrote:
Can you try with curl:
curl -u 'user:pass' --digest http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put All the examples seem to suggest that this should work, and it uses a regular GET request.
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-189934798.
Thanks for the quick response.
Huh, the Indigo RESTful Overview certainly makes it seem like the two should be equivalent, I'm not sure why one is working and not the other:
curl -u 'user:pass' --digest -X PUT -d 'isOn=1' http://localhost/indigo/devices/Hall%20Light
curl -u 'user:pass' --digest http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put
Any ideas? Just to verify, I'm sure you're changing isOn=1
to isOn=0
as appropriate to make sure the device is being turned on vs off, correct?
Yes and, even better, I’m monitoring my Indigo log to see if anything is hitting the server, whether it is an on command or an off command.
On Feb 28, 2016, at 1:15 PM, Nathan Henrie notifications@github.com wrote:
Thanks for the quick response.
Huh, the Indigo RESTful Overview http://wiki.indigodomo.com/doku.php?id=indigo_s_restful_urls certainly makes it seem like the two should be equivalent, I'm not sure why one is working and not the other:
curl -u 'user:pass' --digest -X PUT -d 'isOn=1' http://localhost/indigo/devices/Hall%20Light curl -u 'user:pass' --digest http://localhost/indigo/devices/Hall%20Light?isOn=1&_method=put Any ideas? Just to verify, I'm sure you're changing isOn=1 to isOn=0 as appropriate to make sure the device is being turned on vs off, correct?
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-189947053.
I felt bad about making you run all these tests, so I downloaded the 30 day free trial.
You're right, for some reason, the _method=put
URL doesn't seem to work... unless I put quotes around the URL. I think the ampersand is likely screwing up the command and needs to be quoted (sorry I didn't think of that before).
Can you give that a shot and confirm?
That worked! And please don’t worry about the tests. Even though I don’t necessarily need this because of the plugin I mentioned, others may benefit. And who knows? Maybe I’ll need it someday if something stops working with the plugin.
Thanks for your efforts.
—Dave
On Feb 28, 2016, at 11:45 PM, Nathan Henrie notifications@github.com wrote:
I felt bad about making you run all these tests, so I downloaded the 30 day free trial.
You're right, for some reason, the _method=put URL doesn't seem to work... unless I put quotes around the URL. I think the ampersand is likely screwing up the command and needs to be quoted (sorry I didn't think of that before).
Can you give that a shot and confirm?
— Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-190079508.
I have a commit pushed to the dev branch (a5f9c4df87501d4f954d46e565d15e7f73f838a0) that should work with Indigo. Can you give it a shot?
To install dev branch:
pip install git+https://github.com/n8henrie/fauxmo.git@dev
You will need to change your config slightly, see the new indigo example in the dev branch's config sample.
I tried to install it but got the following error:
Could not import setuptools which is required to install from a source distribution. Please install setuptools.
I tried to install setuptools but must have done it wrong since I still get the error. Any advice?
Thanks.
—Dave
On Mar 24, 2016, at 10:59 AM, Nathan Henrie notifications@github.com wrote:
I have a commit pushed to the dev branch that should work with Indigo. Can you give it a shot?
To install dev branch:
pip install git+https://github.com/n8henrie/fauxmo.git@dev You will need to change your config slightly, see the new indigo example in the dev branch's config sample.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-200950693
Are you trying to install in a virtual env? If so, can you delete and recreate the env? If not, can you try one?
python3 -m venv venv
source venv/bin/activate
pip install...
I was able to get it working by properly specifying Python3 for the easy setup. It seems to work for both devices and actions. Congrats!
—Dave
On Mar 24, 2016, at 2:33 PM, Nathan Henrie notifications@github.com wrote:
Are you trying to install in a virtual env? If so, can you delete and recreate the env? If not, can you try one?
python3 -m venv venv source venv/bin/activate pip install... — You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/n8henrie/fauxmo/issues/3#issuecomment-201033512
Fantastic. I'll likely merge with master after a touch more testing and a few other minor changes. Thanks for your help and feedback.
Now that I've got Fauxmo running, I'm trying to use it to send URLs to my Indigo home automation app running on the same server. Unfortunately, I can't seem to figure out how to send URLs with usernames and passwords and I can't turn off authentication since it's accessed from the outside. My workaround is to use Home Remote as an intermediary server and turn off its authentication since it is only used internally on my LAN.
When I try to embed a username and password in the URL, fauxmo gives no error but Alexa complains that "That command doesn’t work on that device." This happens with both Indigo and Home Remote.
Is there any trick to using authentication with fauxmo?