Advertisement
Guest User

Untitled

a guest
Sep 7th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <system.webServer>
  2. <httpProtocol>
  3. <customHeaders>
  4. <clear />
  5. <add name="Access-Control-Allow-Origin" value="http://localhost:63180" />
  6. <add name="Access-Control-Allow-Headers" value="Content-Type"/>
  7. </customHeaders>
  8. </httpProtocol>
  9. .
  10. .
  11. .
  12.  
  13. public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider
  14. {
  15. .
  16. .
  17. .
  18. public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
  19. {
  20. .
  21. .
  22. .
  23. context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin",
  24. new[] { "http://localhost:63180" });
  25. .
  26. .
  27. .
  28. }
  29.  
  30. (function () {
  31. "use strict";
  32. angular.module("common.services")
  33. .factory("accountResource",
  34. ["$resource", accountResource]);
  35.  
  36. function accountResource($resource) {
  37. return {
  38. registration: $resource("http://localhost:57939/api/Account/Register", null,
  39. {
  40. 'registerUser': { metod: 'POST' }
  41. }),
  42. login: $resource("http://localhost:57939/Token", null,
  43. {
  44. 'loginUser': {
  45. metod: 'POST',
  46. headers: {
  47. 'Content-Type': 'application/x-www-form-urlencoded'
  48. },
  49. withCredentials: false,
  50. transformRequest: function (data, headersGetter) {
  51. var strArr = [];
  52. for (var item in data) {
  53. strArr.push(encodeURIComponent(item) + "=" +
  54. encodeURIComponent(data[item]));
  55. }
  56. return strArr.join("&");
  57. }
  58. }
  59. })
  60. }
  61. }
  62.  
  63. }());
  64.  
  65. GET /Token?grant_type=password&password=a&userName=a HTTP/1.1
  66. Host: localhost:57939
  67. Connection: keep-alive
  68. Accept: application/json, text/plain, */*
  69. Origin: http://localhost:63180
  70. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36
  71. Content-Type: application/x-www-form-urlencoded
  72. Referer: http://localhost:63180/
  73. Accept-Encoding: gzip, deflate, sdch
  74. Accept-Language: he-IL,he;q=0.8,en-US;q=0.6,en;q=0.4
  75.  
  76. grant_type:password
  77. password:a
  78. userName:a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement