Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. var json ={};
  2. json.client_id= "webshop_client";
  3. json.client_secret= "639a9118-b4ff-4617-86b2-50dcd20af961";
  4. json.grant_type="password";
  5. json.username="someusename";
  6. json.password ="somepassword";
  7.  
  8.  
  9. var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
  10. xhttp = new XMLHttpRequest();
  11. var url1="somrurl";
  12. xhttp.onreadystatechange = function () {
  13. console.log(xhttp.readyState+"||"+xhttp.status);
  14. if(xhttp.readyState == 4 && xhttp.status == 200){
  15. console.log(xhttp.responseText);
  16. service_response = JSON.parse(xhttp.responseText);
  17. accessToken = service_response.access_token;
  18. return callback(accessToken);
  19. }
  20. }
  21. xhttp.open("POST",url1,true);
  22. xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  23. xhttp.send(JSON.stringify(json));
  24.  
  25. xhttp.withCredentials = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement