omniauth-weibo-oauth2 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +18 -1
- data/lib/omniauth-weibo-oauth2/version.rb +1 -1
- data/lib/omniauth/strategies/weibo.rb +34 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe54685243b852c2b36db7c8941649832752d5a7
|
4
|
+
data.tar.gz: c4a570f19b52f3611335e938b3be5ca9ae95cbbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5312a966758f9466724b1f0c46b8cdcc18bd366e015ab10c9fac98e3754b41deff5bf5eb677e6677f16c6016d2003db300f66caa93f3b745a986a3b8e890f44a
|
7
|
+
data.tar.gz: 69bc78cf85bb5e29755c09dbe5938a87dd3bb7f76f40ee881ff0d91198d06fc510ae7ab2cc5de1a41117ffba26b3dae45c5496b83603a24a7129d10833618041
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,23 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
29
29
|
provider :weibo, ENV['WEIBO_KEY'], ENV['WEIBO_SECRET']
|
30
30
|
end
|
31
31
|
```
|
32
|
+
## Configuration
|
33
|
+
|
34
|
+
you can set up redirect_uri in `omniauth.rb` as following:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
provider :weibo, ENV['WEIBO_KEY'], ENV['WEIBO_SECRET'],
|
38
|
+
token_params: {redirect_uri: "http://127.0.0.1:3000/auth/weibo/callback" }
|
39
|
+
```
|
40
|
+
|
41
|
+
## Authentication Option
|
42
|
+
* **image_size**: This option defines the size of the user's image in *Authentication Hash* (info['image']). Valid options include `small` (30x30), `middle` (50x50), `large` (180x180) and `original` (the size of the image originally uploaded). Default is `middle`.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
46
|
+
provider :weibo, ENV['WEIBO_KEY'], ENV['WEIBO_SECRET'], :image_size => 'original'
|
47
|
+
end
|
48
|
+
```
|
32
49
|
|
33
50
|
## Authentication Hash
|
34
51
|
|
@@ -78,4 +95,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
78
95
|
|
79
96
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
80
97
|
|
81
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
98
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -6,7 +6,8 @@ module OmniAuth
|
|
6
6
|
option :client_options, {
|
7
7
|
:site => "https://api.weibo.com",
|
8
8
|
:authorize_url => "/oauth2/authorize",
|
9
|
-
:token_url => "/oauth2/access_token"
|
9
|
+
:token_url => "/oauth2/access_token",
|
10
|
+
:token_method => :post
|
10
11
|
}
|
11
12
|
option :token_params, {
|
12
13
|
:parse => :json
|
@@ -21,7 +22,7 @@ module OmniAuth
|
|
21
22
|
:nickname => raw_info['screen_name'],
|
22
23
|
:name => raw_info['name'],
|
23
24
|
:location => raw_info['location'],
|
24
|
-
:image =>
|
25
|
+
:image => image_url,
|
25
26
|
:description => raw_info['description'],
|
26
27
|
:urls => {
|
27
28
|
'Blog' => raw_info['url'],
|
@@ -47,6 +48,25 @@ module OmniAuth
|
|
47
48
|
raw_info[%w(avatar_hd avatar_large profile_image_url).find { |e| raw_info[e].present? }]
|
48
49
|
end
|
49
50
|
|
51
|
+
#url: option: size:
|
52
|
+
#avatar_hd original original_size
|
53
|
+
#avatar_large large 180x180
|
54
|
+
#profile_image_url middle 50x50
|
55
|
+
# small 30x30
|
56
|
+
#default is middle
|
57
|
+
def image_url
|
58
|
+
case options[:image_size].to_sym
|
59
|
+
when :original
|
60
|
+
url = raw_info['avatar_hd']
|
61
|
+
when :large
|
62
|
+
url = raw_info['avatar_large']
|
63
|
+
when :small
|
64
|
+
url = raw_info['avatar_large'].sub('/180/','/30/')
|
65
|
+
else
|
66
|
+
url = raw_info['profile_image_url']
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
##
|
51
71
|
# You can pass +display+, +with_offical_account+ or +state+ params to the auth request, if
|
52
72
|
# you need to set them dynamically. You can also set these options
|
@@ -63,7 +83,18 @@ module OmniAuth
|
|
63
83
|
end
|
64
84
|
end
|
65
85
|
end
|
66
|
-
|
86
|
+
|
87
|
+
protected
|
88
|
+
def build_access_token
|
89
|
+
params = {
|
90
|
+
'client_id' => client.id,
|
91
|
+
'client_secret' => client.secret,
|
92
|
+
'code' => request.params['code'],
|
93
|
+
'grant_type' => 'authorization_code'
|
94
|
+
}.merge(token_params.to_hash(symbolize_keys: true))
|
95
|
+
client.get_token(params, deep_symbolize(options.auth_token_params))
|
96
|
+
end
|
97
|
+
|
67
98
|
end
|
68
99
|
end
|
69
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-weibo-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bin He
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.4.6
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: OmniAuth Oauth2 strategy for weibo.com.
|