# HTTP Request Flow with username/password

**URL:** <https://community.homey.app/t/http-request-flow-with-username-password/51210>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [September 6, 2021, 7:58pm UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210 "2021-09-06T19:58:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WilcodeBoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wilcodeboer/32/35879_2.png) [@WilcodeBoer](https://community.homey.app/u/WilcodeBoer)\
**Post date:** [September 6, 2021, 7:58pm UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/1 "2021-09-06T19:58:14Z")

</div>

Now my Homey is running for a while very stable, I want to move to the next level :-).

My sauna is Wifi controlled with HUUM controller. I would like to be able to turn on sauna to a fix temperature and automatically turn on the lights as well. There is a basic API available: [https://github.com/horemansp/HUUM](https://github.com/horemansp/HUUM)

I tried several URLs and I believe I can make it work with the Homey App “HTTP Request Flow card”. However, after entering the URLs to access API, it always asks for my username/password first. Here I get stuck, as I am not sure how to bring this with the GET option into the flow card.

Any ideas how to make this HUUM controller work under Homey?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 6, 2021, 8:58pm UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/2 "2021-09-06T20:58:38Z")

</div>

An idea: First try it in a browser like this:  
`http://username:password@example.com/`  
In your case as a POST request:  
`https://username:password@api.huum.eu/action/home/start?targetTemperature=80`  
(http or https? Just try)

If that works, without being asked for your credentials, (and the heater is switched on to 80°C),  
you can use it in your HTTP request flow card

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [September 7, 2021, 1:01pm UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/3 "2021-09-07T13:01:41Z")

</div>

I think i could be possible with http request, and maybe a little easier with logic, make a webrequest.

I also found a begin of the solution for Homeyscript. I think if you adjust this script it can work

> var token\_ // variable will store the token  
> var userName = “clientID”; // app clientID  
> var passWord = “secretKey”; // app clientSecret  
> var caspioTokenUrl = “[https://xxx123.caspio.com/oauth/token](https://xxx123.caspio.com/oauth/token)”; // Your application token endpoint  
> var request = new XMLHttpRequest();
> 
> function getToken(url, clientID, clientSecret) {  
> var key;  
> request.open(“POST”, url, true);  
> request.setRequestHeader(“Content-type”, “application/json”);  
> request.send(“grant\_type=client\_credentials&client\_id=”+clientID+“&”+“client\_secret=”+clientSecret); // specify the credentials to receive the token on request  
> request.onreadystatechange = function () {  
> if (request.readyState == request.DONE) {  
> var response = request.responseText;  
> var obj = JSON.parse(response);  
> key = obj.access\_token; //store the value of the accesstoken  
> token\_ = key; // store token in your global variable “token\_” or you could simply return the value of the access token from the function  
> }  
> }  
> }  
> // Get the token  
> getToken(caspioTokenUrl, userName, passWordz);

---

<div class="post-metadata">

**Author:** ![WilcodeBoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wilcodeboer/32/35879_2.png) [@WilcodeBoer](https://community.homey.app/u/WilcodeBoer)\
**Post date:** [September 11, 2021, 6:59am UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/4 "2021-09-11T06:59:50Z")

</div>

Peter, many thanks! This works well… I can now toggle the light and turn off the sauna. I am sure I should be able to fix the start as well. The flow card seems not to handle the PUT perfect, but I guess I need to play with the arguments. Status request I did not try yet, but I guess I can use that to get status string in a variable.

---

<div class="post-metadata">

**Author:** ![WilcodeBoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wilcodeboer/32/35879_2.png) [@WilcodeBoer](https://community.homey.app/u/WilcodeBoer)\
**Post date:** [September 11, 2021, 7:01am UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/5 "2021-09-11T07:01:02Z")

</div>

Marcel, I believe your suggestion makes it even better as I can directly make dependencies in the script. E.g. to really turn on or off the ligth based on status instead of toggling. But also bit more complex… Looking forward to a rainy weekend to try that.

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [September 11, 2021, 7:50am UTC](https://community.homey.app/t/http-request-flow-with-username-password/51210/6 "2021-09-11T07:50:04Z")

</div>

Looking forward to your solution. I to am struggling with the autorisation. I also want this script to use. It is in my to do list. But at this moment i am still trying to get my solarpanel script to work fully. But because i am not a real scripter it takes quit some time. If you are ahead if me it would nice to publish it here. When i get to it i will also publish it here
