omniauth-weibo-oauth2 0.4.0 → 0.4.2

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: 2447724a9eb14cae153f4df299a230ac70a6b5c8
4
- data.tar.gz: a043480c8c10a7a9d33e1b58501801aa5bc0da3d
3
+ metadata.gz: 9c90da889897455e5e4761ed5ee66ef40a5d9763
4
+ data.tar.gz: 450175fbfeb1cb8c53012f282fd675e178baf72e
5
5
  SHA512:
6
- metadata.gz: a86e6ca738c3bbb9aa84b47d7bb672b64497cb8d48a32fd1fd4e900bac60dcaa10225da9cc42dbe9601c2761a687e39067772c21f4fb0e6f11603c2b4479e7d1
7
- data.tar.gz: 3db001dc2e88b7b5396942d95f2905123bd4e8b713cbdb0abed5995b23a7e86d42a04687ab5f7a160680513b0074afd33c148900cb46377eb9c5270e30fab23a
6
+ metadata.gz: 5b619ddbc6ff1a0163958a13c2d004d689746ddc6accd56d3bdefd1b11b87378fe4b15357a15d357ca5f89a5c62420ab8ce08d387a66afb9d9334312544f10d0
7
+ data.tar.gz: 143eede4cdd702e319ee9d7f10a938ee380a51d87e908f9f4b261e12859663a64634fd11a78575911acf991d1d0d5581cecd370832d13a46851bc6cbdd2df0f7
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .bundle
2
2
  *.swp
3
+ .gem
3
4
  Gemfile.lock
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.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module WeiboOauth2
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
@@ -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,11 +22,11 @@ module OmniAuth
21
22
  :nickname => raw_info['screen_name'],
22
23
  :name => raw_info['name'],
23
24
  :location => raw_info['location'],
24
- :image => find_image,
25
+ :image => image_url,
25
26
  :description => raw_info['description'],
26
27
  :urls => {
27
28
  'Blog' => raw_info['url'],
28
- 'Weibo' => raw_info['domain'].present?? "http://weibo.com/#{raw_info['domain']}" : "http://weibo.com/u/#{raw_info['id']}",
29
+ 'Weibo' => raw_info['domain'].empty? ? "http://weibo.com/u/#{raw_info['id']}" : "http://weibo.com/#{raw_info['domain']}",
29
30
  }
30
31
  }
31
32
  end
@@ -47,6 +48,26 @@ 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
+ image_size = options[:image_size] || :middle
59
+ case image_size.to_sym
60
+ when :original
61
+ url = raw_info['avatar_hd']
62
+ when :large
63
+ url = raw_info['avatar_large']
64
+ when :small
65
+ url = raw_info['avatar_large'].sub('/180/','/30/')
66
+ else
67
+ url = raw_info['profile_image_url']
68
+ end
69
+ end
70
+
50
71
  ##
51
72
  # You can pass +display+, +with_offical_account+ or +state+ params to the auth request, if
52
73
  # you need to set them dynamically. You can also set these options
@@ -63,7 +84,18 @@ module OmniAuth
63
84
  end
64
85
  end
65
86
  end
66
-
87
+
88
+ protected
89
+ def build_access_token
90
+ params = {
91
+ 'client_id' => client.id,
92
+ 'client_secret' => client.secret,
93
+ 'code' => request.params['code'],
94
+ 'grant_type' => 'authorization_code'
95
+ }.merge(token_params.to_hash(symbolize_keys: true))
96
+ client.get_token(params, deep_symbolize(options.auth_token_params))
97
+ end
98
+
67
99
  end
68
100
  end
69
101
  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.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bin He
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-23 00:00:00.000000000 Z
11
+ date: 2016-11-01 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.2.2
73
+ rubygems_version: 2.6.7
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: OmniAuth Oauth2 strategy for weibo.com.