[quote=“sirpinky, post:44, topic:181032”][quote=“amg0, post:41, topic:181032”]Hello all
Thanks to Richard excellent notes which I followed strictly , I managed to build a HTML / JS page which gets user login & pwd and do all the MMS protocol to get the list of units. it works absolutely fine and I get back the expected device table in JSON like these:
{“PK_Device”:“35101627”,“PK_DeviceType”:“1”,“PK_DeviceSubType”:“2”,“MacAddress”:“00:0e:8f:7f:71:ab”,“Server_Device”:“vera-us-oem-device12.mios.com”,“Server_Device_Alt”:“vera-us-oem-device11.mios.com”,“PK_Installation”:“256712”,“DeviceAssigned”:“2015-01-31 22:55:10”}
{“PK_Device”:“45101392”,“PK_DeviceType”:“1”,“PK_DeviceSubType”:“2”,“MacAddress”:“d4:21:22:fc:cc:ad”,“Server_Device”:“vera-us-oem-device11.mios.com”,“Server_Device_Alt”:“vera-us-oem-device12.mios.com”,“PK_Installation”:“256712”,“Using_2G”:“0”,“DeviceAssigned”:“2015-02-16 12:10:46”}
But …
it only works when I disable Chrome Same Origin Domain policy ( with the cmd line flag --disable-web-security ). this is normal & expected because the web server hosting my page is not in the same domain as VERA MMS servers and the VERA MMS servers do not have the proper CORS allowance headers in the response.
Now the question is how do I get around that ? I need to offer a login page which is available when I am out of the home to perform the authentication and then to access VERA remotely. How do people go around the some domain origin issue ? is it because I use jQuery ?
attached my page code ( single page , and a screen shot that shows the result when it works by disabling same domain origin security )
thx for your help
Alexis[/quote]
I played with your html/scripts (which is kind of a specialty of mine in case anyone else need/want help)
There is one bug I think I found:
in getSessionToken you build the URL “https://”+server+“/info/session/token”;
but according to the TO text file notes, this request needs to go to this URL hard coded: “https://us-authd11.mios.com/info/session/token”;
changed that, but still not working. I’m getting an error my server is not allowed to make CORS requests to us-authd11.mios.com, this is something they block on their server. This it why it would work from .NET or other platforms, and won’t work from JavaScript.
You are using local file - which will never work with CORS, I hosted it on my http://localhost:4422 and it was still rejected.
One more note: you should use request type “jsonp” for cross origin support, but again if it is blocked at the server there is nothing you can do.
shame
Did anyone get any luck accessing this via pure JavaScript? This is something I would be very interested in, as I could build a very simple mobile friendly responsive UI page that does the basic day to day operations without bothering with hosting/running server side code.[/quote]
Sirpinky
I think the “https://”+server+“/info/session/token” is correct, it is the doc which is wrong i believe ( not 100% sure ), I believe we are supposed to dynamically get the server name for load balancing or High availability reason. However it does not make a great deal of difference
the BIG problem is the lack of CORS support on vera side servers. without that, and without them supporting jsonp we cannot have a javascript client side approach unfortunately. I think with a command flag when you launch chrome you can disable all the CORS security enforcement made by the browser and in that case you will see it working fine if I remember (“Chrome --args --disable-web-security”)
so I did get this whole thing working but with PHP. This url https://vera-ui.strongcubedfitness.com/Veralogin.php is the external MMS login facitiliy for my ALTUI plugin (MiOS Apps)