Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. var results = $.ajax({
  2.  
  3. // The URL to process the request
  4. url : "https://app1pub.smappee.net/dev/v1/oauth2/token",
  5. type : "POST",
  6. data : {
  7. grant_type : "password",//jshint ignore:line
  8. username: "myuser",
  9. password: "secret",
  10. client_id: "myclient",//jshint ignore:line
  11. client_secret: "clientSecret"//jshint ignore:line
  12.  
  13. },
  14. beforeSend: function (xhr) {
  15. xhr.setRequestHeader("Authorization", "Bearer $token");
  16. xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
  17. },
  18. dataType: "json",
  19. contentType: "application/x-www-form-urlencoded",
  20. success: function(response) {
  21. //console.log(response);
  22. console.log(response.access_token);//jshint ignore:line
  23. data.access_token = response.access_token;//jshint ignore:line
  24. //tokenGranted();
  25. }
  26.  
  27. });
  28.  
  29. return results.responseText;
  30.  
  31. "XMLHttpRequest cannot load https://app1pub.smappee.net/dev/v1/oauth2/token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement