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 +4 -4
- data/lib/omniauth-qzone/version.rb +1 -1
- data/lib/omniauth-qzone/version.rb~ +5 -0
- data/lib/omniauth/strategies/qzone.rb +2 -2
- data/lib/omniauth/strategies/qzone.rb~ +64 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add14e75ee2c096390caa09af62eb667c9a84807
|
4
|
+
data.tar.gz: 793a2501950e84d19dd50b6b8a3cc7e87cad1146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47646742befedb3570e6372e3dab9992a8c2349ff50a574639afddb3edd81d474bb378b338b98c88a4b0d18584ae750e745784607c394e8063ca8e1774677f40
|
7
|
+
data.tar.gz: f62b30c03da17f0a340def1d279c2bb3ea545cfd957076e2bb49c6a8c5323da313d40071672ff1b6f34c39c13b973c6c9c0fcbf1725c5b552948359f776577d6
|
@@ -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.
|
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: []
|