# 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:** 1\
**Showing post:** 3

<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);

---

_[View the full topic](https://community.homey.app/t/http-request-flow-with-username-password/51210)._
