Commit 6d4f6ca10ffa4e747d85128af833f90a35457c63
1 parent
9f4bb336
Exists in
master
General bug fixes
Showing
3 changed files
with
10 additions
and
8 deletions
Show diff stats
lib/dingtalk/api/base.rb
@@ -43,12 +43,14 @@ module Dingtalk | @@ -43,12 +43,14 @@ module Dingtalk | ||
43 | end | 43 | end |
44 | 44 | ||
45 | def http_get(url, params = {}) | 45 | def http_get(url, params = {}) |
46 | - res = RestClient.get(*payload(url, params)) | 46 | + p = default_params.merge(params) |
47 | + res = RestClient.get(request_url(url), p.to_json, content_type: :json) | ||
47 | JSON.parse(res) | 48 | JSON.parse(res) |
48 | end | 49 | end |
49 | 50 | ||
50 | def http_post(url, params = {}) | 51 | def http_post(url, params = {}) |
51 | - res = RestClient.post(*payload(url, params)) | 52 | + p = default_params.merge(params) |
53 | + res = RestClient.post(request_url(url), p.to_json, content_type: :json) | ||
52 | JSON.parse(res) | 54 | JSON.parse(res) |
53 | end | 55 | end |
54 | 56 |
lib/dingtalk/api/suite.rb
@@ -12,10 +12,9 @@ module Dingtalk | @@ -12,10 +12,9 @@ module Dingtalk | ||
12 | 12 | ||
13 | def get_permanent_code(tmp_auth_code) | 13 | def get_permanent_code(tmp_auth_code) |
14 | params = { | 14 | params = { |
15 | - suite_access_token: suite_access_token, | ||
16 | tmp_auth_code: tmp_auth_code | 15 | tmp_auth_code: tmp_auth_code |
17 | } | 16 | } |
18 | - http_post('get_permanent_code', params) | 17 | + http_post("get_permanent_code?suite_access_token=#{suite_access_token}", params) |
19 | end | 18 | end |
20 | 19 | ||
21 | def suite_access_token | 20 | def suite_access_token |
lib/dingtalk/client.rb
@@ -11,9 +11,10 @@ module Dingtalk | @@ -11,9 +11,10 @@ module Dingtalk | ||
11 | def response_json(return_str) | 11 | def response_json(return_str) |
12 | the_timestamp = timestamp | 12 | the_timestamp = timestamp |
13 | the_nonce = nonce | 13 | the_nonce = nonce |
14 | + encrypted = encrypt(return_str) | ||
14 | { | 15 | { |
15 | - msg_signature: signature(return_str, the_timestamp, the_nonce), | ||
16 | - encrypt: encrypt(return_str), | 16 | + msg_signature: signature(return_str, encrypted, the_timestamp, the_nonce), |
17 | + encrypt: encrypted, | ||
17 | timeStamp: the_timestamp, | 18 | timeStamp: the_timestamp, |
18 | nonce: the_nonce | 19 | nonce: the_nonce |
19 | } | 20 | } |
@@ -23,8 +24,8 @@ module Dingtalk | @@ -23,8 +24,8 @@ module Dingtalk | ||
23 | encrypt = Dingtalk::Prpcrypt.encrypt(aes_key, return_str, Dingtalk.suite_key) | 24 | encrypt = Dingtalk::Prpcrypt.encrypt(aes_key, return_str, Dingtalk.suite_key) |
24 | end | 25 | end |
25 | 26 | ||
26 | - def signature(return_str, timestamp, nonce) | ||
27 | - sort_params = [Dingtalk.suite_token, timestamp, nonce, encrypt(return_str)].sort.join | 27 | + def signature(return_str, encrypted, the_timestamp, the_nonce) |
28 | + sort_params = [Dingtalk.suite_token, the_timestamp, the_nonce, encrypted].sort.join | ||
28 | Digest::SHA1.hexdigest(sort_params) | 29 | Digest::SHA1.hexdigest(sort_params) |
29 | end | 30 | end |
30 | 31 |