Guest User

Untitled

a guest
Jun 1st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. {"$id"=>"1", "Message"=>"Authorization has been denied for this request."}
  2.  
  3. # Service object
  4. class Abc
  5. include HTTParty
  6. base_uri 'api.thirdparty.com'
  7.  
  8. def questions
  9. result = self.class.post("/end_point/of/third/party/", body: {key: value,...})
  10. result # error in result : {"$id"=>"1", "Message"=>"Authorization has been denied for this request."}
  11. end
  12. end
  13.  
  14. # request header
  15. {
  16. content-type:"application/json"
  17. cache-control:"no-cache"
  18. postman-token:"94a40ead-1e76-41ab-9563-172f656f213a"
  19. user-agent:"PostmanRuntime/7.1.5"
  20. accept:"*/*"
  21. host:"happiness.com"
  22. accept-encoding:"gzip, deflate"
  23. content-length:137
  24. }
  25.  
  26. # Request body
  27. {
  28. password:"1234567890"
  29. password_confirmation:"1234567890"
  30. approve_policy:true
  31. telephone:"xx832xxxxxxx"
  32. step:4
  33. }
  34.  
  35. # Response header
  36. {
  37. content-type:"application/json; charset=utf-8"
  38. transfer-encoding:"chunked"
  39. connection:"keep-alive"
  40. status:"200 OK"
  41. cache-control:"max-age=0, private, must-revalidate"
  42. strict-transport-security:"max-age=15552000; includeSubDomains"
  43. x-request-id:"e11c82ed-e828-4c5e-b8b9-ae477be18a81"
  44. etag:"W/"1eca77bcc78b5bada08cb47c78aa04e1""
  45. x-runtime:"0.789290"
  46. date:"Fri, 01 Jun 2018 10:32:47 GMT"
  47. x-powered-by:"Phusion Passenger 5.2.3"
  48. server:"nginx/1.12.2 + Phusion Passenger 5.2.3"
  49. }
  50.  
  51. # Response body (customized)
  52. {
  53. status:"0"
  54. status_code:422
  55. message:"Authorization has been denied for this request."
  56. }
  57.  
  58. # app/lib/connection.rb
  59. class Connection
  60. include HTTParty
  61. base_uri "https://anotherserver.com"
  62.  
  63. def register
  64. response = HTTParty.post('/api/tenantAccounts/', body: create_request_body, headers: auth_header)
  65. response # <= {"$id"=>"1", "Message"=>"Authorization has been denied for this request."}
  66. end
  67.  
  68. def request_body
  69. {
  70. "accountPassword": "123456",
  71. "tenantAccountCode": "prod-dr104",
  72. "accountUserName": "jignesh-khokhani-104",
  73. "accountLockStatus": 0,
  74. "loginFailNum": 0,
  75. "birthDate": "Sun, 01 Jun 1958 19:25:16 JST +09:00",
  76. "restingHr": 80,
  77. "maxHr": 160,
  78. "normalHr": 100,
  79. "upperLimitHr": 180,
  80. "lowerLimitHr": 60,
  81. "durationHr": 60,
  82. "duration180Hs": 60,
  83. "duration220Hs": 60,
  84. "thresholdDurationHs": 60,
  85. "thresholdDurationWs": 60,
  86. "imageFlg": "0",
  87. "createAccountId": "10003608"
  88. }
  89. end
  90.  
  91. private
  92.  
  93. def auth_header
  94. {
  95. 'Authorization': "bearer #{auth_details.access_token}"
  96. }
  97. end
  98.  
  99. def auth_details
  100. # 3rd party server login and get token
  101. HTTParty.post('/login', {
  102. body: {
  103. username: 'username',
  104. password: 'secret_password,
  105. scope: 'scope',
  106. grant_type: 'password'
  107. }
  108. })
  109. end
  110. end
Add Comment
Please, Sign In to add comment