omniauth-taobao-oauth2 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0a4b472c58fde2d5b01d1ecc4a6dc9c2870be33
4
- data.tar.gz: dd59b20acde3bac76709fd735281afa7dbd82244
3
+ metadata.gz: a5da4db12baf886b3273434deb4c092a7e19ae02
4
+ data.tar.gz: 26352f54eb7d33f59fbeb887c8f692d745e7603a
5
5
  SHA512:
6
- metadata.gz: 034c050ab97d9a10d6dd80afc1c5e2074450c8c2d1321a07f4b57e8b71d67971f042c5d8a3c60d2879335410be11c5691676f1b288f7e8a7e8e5087be477b97f
7
- data.tar.gz: 9b935c8601b6e12123b2295e302d5d82c8115995d8a7af27503a5a5718147f397cff003111c9f29065d93e2f11d2bc591e1dde774bf82b4341e2effeddb651fb
6
+ metadata.gz: 04b9c3d372053c74260cfd9587e4235b035825205031b88805a1561361ec6060bc6bd93dbc44f16e671771c75988678a0aaa2370b961b7173f8351bf2815e78f
7
+ data.tar.gz: 1ce693bf7f8e9113a8fc6ae0b8bda9b7e0cb0b881594354efdca958ffdfb802bd611f213e78bd980ccfe93a5bd4e9d86e4d2bd308667606ff6097ac4cf0d0564
Binary file
@@ -1,4 +1,3 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'omniauth-taobao-oauth2/version'
3
- require 'typhoeus/adapters/faraday'
4
3
  require 'omniauth/strategies/taobao'
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Omniauth
3
3
  module TaobaoOauth2
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
@@ -1,5 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'omniauth-oauth2'
3
+ require 'cgi' unless defined?(::CGI)
4
+
3
5
 
4
6
  module OmniAuth
5
7
  module Strategies
@@ -11,61 +13,35 @@ module OmniAuth
11
13
  token_url: "/token"
12
14
  }
13
15
  option :token_params, {
14
- :parse => :json
16
+ parse: :json
15
17
  }
16
18
 
17
19
  uid do
18
- raw_info['user_id']
20
+ user_id
19
21
  end
20
22
 
21
23
  info do
22
24
  {
23
- nickname: raw_info['nick']
25
+ nickname: nickname
24
26
  }
25
27
  end
26
28
 
27
29
  extra do
28
30
  {
29
- raw_info: raw_info
31
+ raw_info: {}
30
32
  }
31
33
  end
32
34
 
33
- def raw_info
34
- access_token.options[:mode] = :query
35
- @raw_info ||= ::OAuth2::Response.new(conn.get("/router/rest", signed_params)).parsed['user_seller_get_response']['user'] rescue {}
36
- end
37
-
38
35
  private
39
36
 
40
- def conn
41
- @conn ||= Faraday.new(url: "http://gw.api.taobao.com") do |req|
42
- req.response :logger
43
- req.adapter :typhoeus
44
- end
45
- end
46
-
47
- def params
48
- {
49
- app_key: client.id,
50
- method: 'taobao.user.seller.get',
51
- fields: 'user_id,nick',
52
- format: 'json',
53
- session: access_token.token,
54
- v: '2.0',
55
- timestamp: timestamp,
56
- partner_id: 'top-apitools'
57
- }
58
- end
59
-
60
- def signed_params
61
- rand = client.secret + params.sort.flatten.join
62
- sign = Digest::MD5.hexdigest(rand).to_s.upcase
63
- params.merge(sign: sign)# 數字簽名
37
+ def nickname
38
+ ::CGI::unescape(access_token.params['taobao_user_nick'].to_s).force_encoding('utf-8')
64
39
  end
65
40
 
66
- def timestamp # 时间戳
67
- Time.now.strftime('%Y-%m-%d %H:%M:%S')
41
+ def user_id
42
+ access_token.params['taobao_user_id'].to_i
68
43
  end
44
+
69
45
  end
70
46
  end
71
47
  end
@@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
21
- spec.add_runtime_dependency "typhoeus"
20
+
22
21
  spec.add_development_dependency "bundler", "~> 1.3"
23
22
  spec.add_development_dependency "rake"
24
23
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-taobao-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Howl王
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-27 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: typhoeus
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +45,7 @@ executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files: []
61
47
  files:
48
+ - ".DS_Store"
62
49
  - ".gitignore"
63
50
  - Gemfile
64
51
  - LICENSE.txt