omniauth-qzone 1.0.0.rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/omniauth/strategies/qzone.rb +58 -0
- data/lib/omniauth-qzone/version.rb +5 -0
- data/lib/omniauth-qzone.rb +2 -0
- metadata +120 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'omniauth-oauth'
|
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::OAuth
|
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
|
+
|
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] }
|
29
|
+
|
30
|
+
info do
|
31
|
+
{
|
32
|
+
'uid' => access_token.params[:openid],
|
33
|
+
'nickname' => raw_info['nickname'],
|
34
|
+
'name' => raw_info['nickname'],
|
35
|
+
'image' => raw_info['figureurl'],
|
36
|
+
'urls' => {
|
37
|
+
'figureurl_1' =>raw_info['figureurl_1'],
|
38
|
+
'figureurl_2' => raw_info['figureurl_2'],
|
39
|
+
},
|
40
|
+
}
|
41
|
+
end
|
42
|
+
extra do
|
43
|
+
{ :raw_info => raw_info }
|
44
|
+
end
|
45
|
+
|
46
|
+
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
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
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
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- zhang ming
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-12-29 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
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
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: omniauth-oauth
|
41
|
+
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
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id002
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: multi_json
|
59
|
+
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"
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id003
|
71
|
+
description: an omniauth strategy for qzone
|
72
|
+
email:
|
73
|
+
- tomorrownull@gmail.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- lib/omniauth-qzone/version.rb
|
82
|
+
- lib/omniauth/strategies/qzone.rb
|
83
|
+
- lib/omniauth-qzone.rb
|
84
|
+
homepage: ""
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- 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
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project: omniauth-qzone
|
115
|
+
rubygems_version: 1.8.11
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: an omniauth strategy for qzone
|
119
|
+
test_files: []
|
120
|
+
|