@yuckon49 Look at my scripts here:
It has login methods for both the published device api as well as the web api.