Getting "unauthorized" for automated submission request

Hi,
I’m trying to utilize the demo script for automated signing submission (https://msdn.microsoft.com/en-us/library/windows/hardware/dn800660(v=vs.85).aspx)
I’m able to get the access token, but when trying to create a submission, I always get “unauthorized” as the response.
Please advise.
Thanks,
Greg

P.S. I’m frankly astonished by the complete lack of information and MS’s lax approach to the topic. The script has obviously never been run, as it doesn’t even compile and contains functions not listed anywhere. How can such an important issue be treated so badly?