I got a partial solution, by abandoning stream and using RESTapi instead.
I logged on with Excel and curl (Documents not downloading, invalid ID - #7 by csmith).
I also got JS/XHR to work - load the client-side file to your server and enter the domain into the ‘create key’ rest section under JavaScript domains.
Thanks for everyones help!