Advertisement
Guest User

Kinvey problem login

a guest
Jul 19th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. const kinveyUsername = "guest";
  2. const kinveyPasssword = "guest";
  3. const appKey = "kid_Syz-eCp-H";
  4. const appSecret = "853929bb0bfd44768b2972fcc9c74253"
  5.  
  6. const baseUrl = 'https://baas.kinvey.com/appdata/kid_Syz-eCp-H/books';
  7.  
  8. function login() {
  9. let url = 'https://baas.kinvey.com/user/kid_Syz-eCp-H/login'
  10.  
  11. let userData = {
  12. username: "guest",
  13. password: "guest"
  14. }
  15.  
  16. let headers = {
  17. method: "POST",
  18. mode: "no-cors",
  19. credentials: "include",
  20. body: JSON.stringify(userData),
  21. headers: {
  22. 'Content-Type': 'application/json',
  23. //Same as "Authorization": "Basic " + btoa(appKey + ':' + appSecret);
  24. "Authorization": "Basic a2lkX1N5ei1lQ3AtSDo4NTM5MjliYjBiZmQ0NDc2OGIyOTcyZmNjOWM3NDI1Mw=="
  25. }
  26. }
  27.  
  28. fetch(url, headers)
  29. .then(res => res.json())
  30. .then(data => console.log(data))
  31. .catch(error => console.error(error));
  32.  
  33. }
  34.  
  35. login();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement