omniauth-qzone 1.0.0.rc → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9be8823a03d8c2f034980ba9de4ad7cc7bb229f7
4
+ data.tar.gz: f10e82480400436c11fd7cc26aa1aa1bc6359d48
5
+ SHA512:
6
+ metadata.gz: efbea2bc66d6e15f7509e716bf4c93f61d963ce2347e9e343ec62c006d8d935446f3c2e16eea257f2d86bd5261bdfea0e78623de3a59daa78592a27fea80034b
7
+ data.tar.gz: 7d73e3888133661abb734abe144f36ae92ba65f4b14bc38bc5e6503dc7c0f3d52d04c8a28ff87caf9dcae95161ff7c05dd37f774d68bab2a474b05b96bb02d8b
@@ -1,31 +1,35 @@
1
- require 'omniauth-oauth'
1
+ require 'omniauth-oauth2'
2
2
  require 'multi_json'
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  #taken from https://github.com/he9qi/omniauth_china/blob/55dac2d2a657d20711459f89dfeb802a8f06c81e/lib/omniauth_china/strategies/qzone.rb
6
- class Qzone < OmniAuth::Strategies::OAuth
6
+ class Qzone < OmniAuth::Strategies::OAuth2
7
7
  option :name, 'qzone'
8
- option :sign_in, true
9
- def initialize(*args)
10
- super
11
- options.client_options = {
12
- :access_token_path => '/oauth/qzoneoauth_access_token',
13
- :authorize_path => '/oauth/qzoneoauth_authorize',
14
- :realm => 'OmniAuth',
15
- :request_token_path => '/oauth/qzoneoauth_request_token',
16
- :site => 'http://openapi.qzone.qq.com',
17
- :scheme => :query_string,
18
- :http_method => :get
19
- }
20
- end
21
8
 
22
- #HACK qzone is using a none-standard parameter oauth_overicode
23
- def callback_phase
24
- options.client_options[:access_token_path] = "/oauth/qzoneoauth_access_token?oauth_vericode=#{request['oauth_vericode'] }" if request['oauth_vericode']
25
- super
26
- end
27
-
28
- uid { access_token.params[:openid] }
9
+ option :client_options, {
10
+ :site => 'https://graph.qq.com/oauth2.0/',
11
+ :authorize_url => '/oauth2.0/authorize',
12
+ :token_url => "/oauth2.0/token"
13
+ }
14
+
15
+ option :token_params, {
16
+ :state => 'foobar',
17
+ :parse => :query
18
+ }
19
+
20
+
21
+ uid {
22
+ @uid ||= begin
23
+ access_token.options[:mode] = :query
24
+ access_token.options[:param_name] = :access_token
25
+ # Response Example: "callback( {\"client_id\":\"11111\",\"openid\":\"000000FFFF\"} );\n"
26
+ response = access_token.get('/oauth2.0/me')
27
+ #TODO handle error case
28
+ matched = response.body.match(/"openid":"(?<openid>\w+)"/)
29
+ matched[:openid]
30
+ end
31
+
32
+ }
29
33
 
30
34
  info do
31
35
  {
@@ -42,17 +46,19 @@ module OmniAuth
42
46
  extra do
43
47
  { :raw_info => raw_info }
44
48
  end
45
-
46
49
  def raw_info
47
- @raw_info ||= MultiJson.decode(access_token.get("/user/get_user_info?format=json&openid=#{access_token.params[:openid]}").body)
48
- rescue ::Errno::ETIMEDOUT
49
- raise ::Timeout::Error
50
- end
51
-
52
- def request_phase
53
- options[:authorize_params].merge!({:oauth_consumer_key=>options.consumer_key})
54
- super
50
+ @raw_info ||= begin
51
+ #TODO handle error case
52
+ #TODO make info request url configurable
53
+
54
+ client.request(:get, "https://graph.qq.com/user/get_user_info", :params => {
55
+ :format => :json,
56
+ :openid => uid,
57
+ :oauth_consumer_key => options[:client_id],
58
+ :access_token => access_token.token
59
+ }, :parse => :json).parsed
60
+ end
55
61
  end
56
62
  end
57
63
  end
58
- end
64
+ end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Qzone
3
- VERSION = "1.0.0.rc"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,120 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: omniauth-qzone
3
- version: !ruby/object:Gem::Version
4
- hash: 7712010
5
- prerelease: 6
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- - rc
11
- version: 1.0.0.rc
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
12
5
  platform: ruby
13
- authors:
6
+ authors:
14
7
  - zhang ming
15
8
  autorequire:
16
9
  bindir: bin
17
10
  cert_chain: []
18
-
19
- date: 2011-12-29 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: omniauth
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 15424049
30
- segments:
31
- - 1
32
- - 0
33
- - 0
34
- - rc
35
- - 2
36
- version: 1.0.0.rc2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
37
20
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
40
- name: omniauth-oauth
41
21
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- hash: 15424049
48
- segments:
49
- - 1
50
- - 0
51
- - 0
52
- - rc
53
- - 2
54
- version: 1.0.0.rc2
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
55
34
  type: :runtime
56
- version_requirements: *id002
57
- - !ruby/object:Gem::Dependency
58
- name: multi_json
59
35
  prerelease: false
60
- requirement: &id003 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- hash: 3
66
- segments:
67
- - 0
68
- version: "0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
69
48
  type: :runtime
70
- version_requirements: *id003
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
71
55
  description: an omniauth strategy for qzone
72
- email:
73
- - tomorrownull@gmail.com
56
+ email:
57
+ - zhangming1021@gmail.com
74
58
  executables: []
75
-
76
59
  extensions: []
77
-
78
60
  extra_rdoc_files: []
79
-
80
- files:
61
+ files:
81
62
  - lib/omniauth-qzone/version.rb
82
63
  - lib/omniauth/strategies/qzone.rb
83
64
  - lib/omniauth-qzone.rb
84
- homepage: ""
65
+ homepage: ''
85
66
  licenses: []
86
-
67
+ metadata: {}
87
68
  post_install_message:
88
69
  rdoc_options: []
89
-
90
- require_paths:
70
+ require_paths:
91
71
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
93
- none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
- requirements:
104
- - - ">"
105
- - !ruby/object:Gem::Version
106
- hash: 25
107
- segments:
108
- - 1
109
- - 3
110
- - 1
111
- version: 1.3.1
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
112
82
  requirements: []
113
-
114
83
  rubyforge_project: omniauth-qzone
115
- rubygems_version: 1.8.11
84
+ rubygems_version: 2.0.3
116
85
  signing_key:
117
- specification_version: 3
86
+ specification_version: 4
118
87
  summary: an omniauth strategy for qzone
119
88
  test_files: []
120
-