Guest User

Untitled

a guest
May 19th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <script>
  2. var token;
  3. $("#getToken1").click(function () {
  4. var user = {
  5. grant_type: 'password',
  6. username: '***@gmail.com',
  7. password: '!aA1234'
  8. };
  9. $.ajax({
  10. type: 'POST',
  11. url: 'http://localhost:65370/Token',
  12. data: user,
  13. success: function (data) {
  14. var parsedResponseBody = JSON.parse(JSON.stringify(data));
  15. token = parsedResponseBody.access_token;
  16. }
  17. });
  18. });
  19. </script>
  20.  
  21. <script>
  22. $("#read1").click(function () {
  23. $.support.cors = true;
  24. $.ajax({
  25. crossDomain: true,
  26. url: 'http://localhost:65370/api/travels',
  27. headers: {
  28. 'Authorization': 'Bearer ' + token
  29. },
  30. type: 'GET',
  31. success: function (data) {
  32. alert(JSON.stringify(data));
  33. }
  34. });
  35. });
  36. </script>
Add Comment
Please, Sign In to add comment