omniauth-qzone 2.0.0 → 2.0.1

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: 9be8823a03d8c2f034980ba9de4ad7cc7bb229f7
4
- data.tar.gz: f10e82480400436c11fd7cc26aa1aa1bc6359d48
3
+ metadata.gz: add14e75ee2c096390caa09af62eb667c9a84807
4
+ data.tar.gz: 793a2501950e84d19dd50b6b8a3cc7e87cad1146
5
5
  SHA512:
6
- metadata.gz: efbea2bc66d6e15f7509e716bf4c93f61d963ce2347e9e343ec62c006d8d935446f3c2e16eea257f2d86bd5261bdfea0e78623de3a59daa78592a27fea80034b
7
- data.tar.gz: 7d73e3888133661abb734abe144f36ae92ba65f4b14bc38bc5e6503dc7c0f3d52d04c8a28ff87caf9dcae95161ff7c05dd37f774d68bab2a474b05b96bb02d8b
6
+ metadata.gz: 47646742befedb3570e6372e3dab9992a8c2349ff50a574639afddb3edd81d474bb378b338b98c88a4b0d18584ae750e745784607c394e8063ca8e1774677f40
7
+ data.tar.gz: f62b30c03da17f0a340def1d279c2bb3ea545cfd957076e2bb49c6a8c5323da313d40071672ff1b6f34c39c13b973c6c9c0fcbf1725c5b552948359f776577d6
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Qzone
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Qzone
3
+ VERSION = "2.0.0"
4
+ end
5
+ end
@@ -1,4 +1,4 @@
1
- require 'omniauth-oauth2'
1
+ require 'omniauth/strategies/oauth2'
2
2
  require 'multi_json'
3
3
  module OmniAuth
4
4
  module Strategies
@@ -61,4 +61,4 @@ module OmniAuth
61
61
  end
62
62
  end
63
63
  end
64
- end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+ module OmniAuth
4
+ module Strategies
5
+ #taken from https://github.com/he9qi/omniauth_china/blob/55dac2d2a657d20711459f89dfeb802a8f06c81e/lib/omniauth_china/strategies/qzone.rb
6
+ class Qzone < OmniAuth::Strategies::OAuth2
7
+ option :name, 'qzone'
8
+
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
+ }
33
+
34
+ info do
35
+ {
36
+ 'uid' => access_token.params[:openid],
37
+ 'nickname' => raw_info['nickname'],
38
+ 'name' => raw_info['nickname'],
39
+ 'image' => raw_info['figureurl'],
40
+ 'urls' => {
41
+ 'figureurl_1' =>raw_info['figureurl_1'],
42
+ 'figureurl_2' => raw_info['figureurl_2'],
43
+ },
44
+ }
45
+ end
46
+ extra do
47
+ { :raw_info => raw_info }
48
+ end
49
+ def raw_info
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
61
+ end
62
+ end
63
+ end
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-qzone
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhang ming
@@ -60,7 +60,9 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - lib/omniauth-qzone/version.rb
63
+ - lib/omniauth-qzone/version.rb~
63
64
  - lib/omniauth/strategies/qzone.rb
65
+ - lib/omniauth/strategies/qzone.rb~
64
66
  - lib/omniauth-qzone.rb
65
67
  homepage: ''
66
68
  licenses: []