FrayAdjacent Posted November 1 Posted November 1 I have experience using the REST API in the older ISYs, but that was over http, using "http://user:pass@mydomain/rest/vars/set/2/1/1". Of course, that's not encrypted, so I tried to avoid that from outside my local network. Well, I've moved to a new house, got married and have a new HA setup with some new devices. I have the Portal URL for my account, so I know how to write up the URL, but how do I end up passing authentication for the http call? In the iOS Shortcuts app you can input the URL, the method (GET will be fine), and there are headers that can be set with KEY/VALUE pairs. I understand the concept, but I don't know what KEY should be used, nor the VALUE. Does my username and password need to be base64 encoded and used as the VALUE? How is it formatted? Just "usernamepassword" or "username/password"? I've only found a few breadcrumbs on how to set it up, haven't found anything that concisely describes out to configure authorization using a key:value pair in headers, or if that's not the way to do it, how can it be done in iOS Shortcuts? Quote
larryllix Posted November 1 Posted November 1 (edited) Yes you need to use base64 encoded using username: password. However this format is basically obsolete and most browsers will not even send it anymore. I don't know anything about iOS. Does it support standard URL formats or is Steve Jobs still around yet? Edited November 1 by larryllix Quote
FrayAdjacent Posted November 1 Author Posted November 1 Ha, I'm not sure about what formats it will accept... but I can pretty easily encode the username:password and test it out. I'm just using the API calls to set variables. I have plenty at this point that won't do anything if I change them. I'm just trying to figure out how to get the basics working, then I'll copy the format for various things I want to do. (I have a variable for when I'm home and when I'm not home... I use the UD Mobile app Geofence to set that, and it works pretty well... the wifey probably doesn't want to mess around with that, so I figured on setting up a Shortcut, then set an Automation for when she leaves the house and when she arrives to set 'her' home variable) Quote
FrayAdjacent Posted November 1 Author Posted November 1 GOT IT. I'll post this for posterity, if anyone wants to use the iOS Shortcuts to make simple API calls. For the URL, get the URL from the UD Portal and use it as the URL for the API call: https://my.isy.io/isy/yourlongidstringgoeshere/rest/vars/set/2/1/0 Under Headers, create one with the KEY "authorization" and the VALUE as "basic yourbase64encodeduserpass" Where your encoded password is "username:password" encoded to base64. 1 Quote
larryllix Posted November 1 Posted November 1 I assume you may not use the GET protocol when using parameters then? Quote
FrayAdjacent Posted November 1 Author Posted November 1 I used GET, it works fine that way. I could see what happens with POST, but it works with GET so I'll leave it like that. Quote
blaine Posted November 2 Posted November 2 This is a timely post as I'm trying to do exactly what the OP wants. I'm getting seriously stuck on how to generate and use the authorization key. I'm simply trying to get things working with the URL in my Chrome browser before I attempt the shortcut in iOS. This is on an EISY. If I go to URL http://192.168.0.50:8080/rest/nodes (I'm using simple things to start), I successfully get all of the ISY nodes listed. If I go to URL https://my.isy.io:8443/rest/nodes, I get a timeout. I've attempted to insert my Base64 encoded password (format username:password) using an online base64 encoder (both normal and URL friendly). I put that string here: https://my.isy.io:8443/encoded_credentials/rest/nodes and again, I obviously get nothing since the non-credential URL timed out. I've tried so many things that I'm now very confused. I concise guide to get this working would be much appreciated. Finally, I'm confused by this statement: "To create the url get "URL to ISY" from Portal or use your local IP Address, then append the rest command i.e. /rest/nodes/<nodeAddress>/cmd/DON" which came from this thread: https://forum.universal-devices.com/topic/42202-trying-to-pass-variable-between-2-isys-using-the-portal/?do=findComment&comment=373777 Is "URL to ISY" a function I'm not seeing, or am I taking it too literally? I'm not finding anything and the URL when I'm logged into Portal is simply https://my.isy.io/index.htm. Thanks Blaine Quote
larryllix Posted November 2 Posted November 2 2 hours ago, blaine said: This is a timely post as I'm trying to do exactly what the OP wants. I'm getting seriously stuck on how to generate and use the authorization key. I'm simply trying to get things working with the URL in my Chrome browser before I attempt the shortcut in iOS. This is on an EISY. If I go to URL http://192.168.0.50:8080/rest/nodes (I'm using simple things to start), I successfully get all of the ISY nodes listed. If I go to URL https://my.isy.io:8443/rest/nodes, I get a timeout. I've attempted to insert my Base64 encoded password (format username:password) using an online base64 encoder (both normal and URL friendly). I put that string here: https://my.isy.io:8443/encoded_credentials/rest/nodes and again, I obviously get nothing since the non-credential URL timed out. I've tried so many things that I'm now very confused. I concise guide to get this working would be much appreciated. Finally, I'm confused by this statement: "To create the url get "URL to ISY" from Portal or use your local IP Address, then append the rest command i.e. /rest/nodes/<nodeAddress>/cmd/DON" which came from this thread: https://forum.universal-devices.com/topic/42202-trying-to-pass-variable-between-2-isys-using-the-portal/?do=findComment&comment=373777 Is "URL to ISY" a function I'm not seeing, or am I taking it too literally? I'm not finding anything and the URL when I'm logged into Portal is simply https://my.isy.io/index.htm. Thanks Blaine Again. I think browsers outlawed this password system and will not pass it from the command URL line. Mine only worked from python3 code lines and my browsers stopped allowing it. It sounds like the iOS system has some special URL sending app, as per a post above. Quote
Guy Lavoie Posted November 2 Posted November 2 (edited) Try encoding it in this order: https://admin:admin@my.isy.io:8443/rest/nodes Replace admin:admin with your own username and password, but in plain text, not base 64 encoded. The base 64 encoding works with a multiline http request. I just tested this successfully on my own eisy, from a chrome browser on Windows 10 to turn on an Insteon switch: http://admin:admin@192.168.0.145:8080/rest/nodes/20 88 BE 1/cmd/DON Edited November 2 by Guy Lavoie Quote
FrayAdjacent Posted November 2 Author Posted November 2 12 hours ago, blaine said: This is a timely post as I'm trying to do exactly what the OP wants. I'm getting seriously stuck on how to generate and use the authorization key. I'm simply trying to get things working with the URL in my Chrome browser before I attempt the shortcut in iOS. This is on an EISY. If I go to URL http://192.168.0.50:8080/rest/nodes (I'm using simple things to start), I successfully get all of the ISY nodes listed. If I go to URL https://my.isy.io:8443/rest/nodes, I get a timeout. I've attempted to insert my Base64 encoded password (format username:password) using an online base64 encoder (both normal and URL friendly). I put that string here: https://my.isy.io:8443/encoded_credentials/rest/nodes and again, I obviously get nothing since the non-credential URL timed out. I've tried so many things that I'm now very confused. I concise guide to get this working would be much appreciated. Finally, I'm confused by this statement: "To create the url get "URL to ISY" from Portal or use your local IP Address, then append the rest command i.e. /rest/nodes/<nodeAddress>/cmd/DON" which came from this thread: https://forum.universal-devices.com/topic/42202-trying-to-pass-variable-between-2-isys-using-the-portal/?do=findComment&comment=373777 Is "URL to ISY" a function I'm not seeing, or am I taking it too literally? I'm not finding anything and the URL when I'm logged into Portal is simply https://my.isy.io/index.htm. Thanks Blaine Blaine, if you're trying to put the URL into a browser tab and get it to do something, you'd need to try the authorization in the URL, like: http://username:password@192.168.0.100/rest/vars/set/1/2/1 That should work locally, though adding :8443 tells the request to go to a specific port. Usually 8443 is a local port that will try to use HTTPS. Publicly outside your local network, anything with 'http' will default to 80 and 'https' will default to 443. Since some ISPs block ports 80 and 443 (to prevent you from running public websites), you may have to set up port forwarding if you want to use a URL like the above. But then you get into things like Dynamic DNS and all that. However, when you're using the ISY Portal, you're talking to the Portal's website, not directly to your ISY. The Portal handles the connection on the back end, so if you're able to, for instance, access your ISY via the UD Mobile app, then it should be configured correctly, and you won't need to tell the my.isy.io URL which port to use. The tricky part there is that the Portal might not accept authorization in the "https://user:pass@my.isy.io/...." format. That's why, when setting up the Shortcut in iOS Shortcuts, you can enter the URL as https://my.isy.io/isy/yourlongidstringgoeshere/rest/vars/set/2/1/0 The "yourlongidstringgoeshere" will be a long string of characters generated specifically for your account. Then in the Shortcut, you click "show more" and you can create the header as I mentioned. To encode the username and password, you can google "base64 encoder" and put in the text, encode it and copy it. Once you have that, copy it to your notepad, or somewhere secure. You'll need it for every Shortcut you create. I hope this is helpful Quote
blaine Posted November 2 Posted November 2 Thank you larryllix, Guy Lavoie and FrayAdjacent. You've cleared up the most confusing aspects of this challenge for me. I misunderstood the part about browsers not supporting this method of passing credentials and I suspect that was my main hurdle to moving forward. FrayAdjacent... I'm using an EISY, so the ports can't be modified. Regardless, your post was helpful. I tried using one of my DDNS entries to no avail, but it really comes back to what Larry clarified. I'll get back to this later this weekend. I'm confident that I'll get there. This is a great group of people! I'm surprised how quickly tips came in. Cheers, Blaine Quote
FrayAdjacent Posted November 3 Author Posted November 3 The screenshot is from the Desktop version of Shortcuts, but it's pretty much identical to what you're gonna see on an iOS device. When you create a new Shortcut, go to Web under Actions, then Get Contents of URL. Paste in your personal URL at my.isy.io. You don't need to use a port if your eISY uses a custom port, as long as the ISY Portal is configured to reach it on that port, or if you have external port 443 forwarded to your internal IP and port. Basically as long as you can talk to your eISY from the Portal, your URL should work, and you shouldn't need to add any port number. Set the Method to Get. It works for REST API calls to set variables, so I haven't bothered to test others, however if you use POST, it will pop up another field. POST is for sending data to a web host, and technically the REST API requests aren't sending anything, you're just requesting a URL, and the request itself is interpreted as an action. With the variables, at least, you can use 'set' and 'get', and the response will be different. When you're setting a variable, the response can be ignored. Add a header by clicking +, then click the field under Key and enter "authentication". Click under Value and enter the string for your base64 encoded username and password, so the field looks like "basic fnasdf329fmasd2390iasdfnsadg" (this is not a real username and password, don't go trying to decode it!" (to get the base64 encoded string, find an encoder online, or google around. I could have done it from Terminal on my Mac with the right commands. You input "username:password" and encode it, and you'll get a string of characters. Copy and save it somewhere secure, you'll need it for every request. If you have Shortcuts syncing with iCloud, new Shortcuts should show up on your iPhone and iPad. You could then add automations (now the location and "connect to WiFi" stuff can work without interaction) Quote
blaine Posted November 3 Posted November 3 (edited) EDIT: I'll leave this post here, but I think my problem is in the "Get contents of URL" command. I'm testing with the format used in the previous post by FrayAdjacent, but so far I'm getting the same resultes. ------------------------------------------------------------- I *think* I'm getting closer, but I'm getting "Authorization missing" when I attempt to run the shortcut from my Mac. Any help is appreciated. I should note that if I run the following command from my browser, it works as expected and turns on the device: https://192.168.0.50:8443/rest/nodes/ZY010_1/cmd/DON/ For clarity, I'm using EISY where the default ports are 8080 and 8443... I have no control over that. The blanked out portion in the image is solely my ISY credentials converted to Base64. The format I used as input to the encoder was "username:password". I entered these same ISY credentials when prompted by my browser to run the REST command within my LAN, so I know they're working. Edited November 3 by blaine Quote
blaine Posted November 3 Posted November 3 (edited) Additional info. For the URL, I just discovered the "URL to ISY" within Portal. It wasn't clear where that came from initially. I'm now using that as my URL with the added REST commands. Regardless, I'm now getting "User authorization not valid" returned from the shortcut. Here's what my current shortcut looks like. The first redacted portion is the key from the "URL to ISY" and the second one is my "username:password" encoded in Base64. I feel like I'm doing everything correctly. EDIT: I used this post from Javi as my template for setting this up: https://forum.universal-devices.com/topic/39832-siri-shortcuts-interface-to-ud-mobile/?do=findComment&comment=356700 Edited November 3 by blaine Quote
blaine Posted November 3 Posted November 3 FINALLY(!!!) got there. I ASSumed that the password was for the ISY and not portal. Once I encoded my portal credentials, all is well. Quote
FrayAdjacent Posted November 4 Author Posted November 4 Ahh yeah, I wasn't quite clear, but when you're accessing the Portal, you have to use the Portal's credentials. It already has your eISY credentials stored, it's just translating the request and sending it the way it normally communicates with your eISY. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.