scavin-weibo-oauth2 0.5.5 → 0.5.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71c6ac3d8281cf957b6b661ec73a9c935de5a3af8f4e52c3dc63fc405a71c0db
4
- data.tar.gz: 7e8541afa82c668c21cb4d62ad06970b899df630ac95600874c8c60de554f538
3
+ metadata.gz: ee14837dc969fc19b8ff0496011aa51033331f48a9247fe463b38b45a3511db4
4
+ data.tar.gz: 80ad22f904f2a589a397e79f8bf57315986e0d282743ff1e69ba90359e888c3c
5
5
  SHA512:
6
- metadata.gz: 0d910da50f95629313e9d09cedc013ced1ef55d530c7c3744cbd9e95cb3f451f46531ac6bce54e2ec73b041a1bf2f9f3334051d1131a3577e29d236704aed8c7
7
- data.tar.gz: 0c3b77497b219e39347abc8276f6756533644f5a799108c3b9b1ed5ccb06441c6fee42ed7833677a4d4153ef1abfd266aba936f50d2f7891ffef7e1e4588da90
6
+ metadata.gz: 9547014ecb3a1fe028a59d0510a3853e5aafd73fe0a4707b18d0df79015ba1372d184921f223db15d19540870fb83671cbc83676481dc986f59597f08c32c65b
7
+ data.tar.gz: 203cca9522e526bfba1e505ef5ce5427b77a55115521ebcc8f015c4ed06491c71a290a27b796547793bae943ad5f0d8efb204dbd7f67eeeaa50e9a39c8fc5d91
@@ -1,8 +1,11 @@
1
1
  require "omniauth-oauth2"
2
+ require "oauth2"
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
5
6
  class Weibo < OmniAuth::Strategies::OAuth2
7
+ class Error < OAuth2::Error; end
8
+
6
9
  option :client_options, {
7
10
  :site => "https://api.weibo.com",
8
11
  :authorize_url => "/oauth2/authorize",
@@ -50,18 +53,14 @@ module OmniAuth
50
53
  access_token.options[:param_name] = 'access_token'
51
54
  @uid ||= access_token.get('/2/account/get_uid.json').parsed["uid"]
52
55
  @raw_info ||= access_token.get("/2/users/show.json", :params => {:uid => @uid}).parsed
56
+ rescue ::OAuth2::Error => e
57
+ raise Error.new(e.response)
53
58
  end
54
59
 
55
60
  def find_image
56
61
  raw_info[%w(avatar_hd avatar_large profile_image_url).find { |e| raw_info[e].present? }]
57
62
  end
58
63
 
59
- #url: option: size:
60
- #avatar_hd original original_size
61
- #avatar_large large 180x180
62
- #profile_image_url middle 50x50
63
- # small 30x30
64
- #default is middle
65
64
  def image_url
66
65
  image_size = options[:image_size] || :middle
67
66
  case image_size.to_sym
@@ -76,13 +75,6 @@ module OmniAuth
76
75
  end
77
76
  end
78
77
 
79
- ##
80
- # You can pass +display+, +with_offical_account+ or +state+ params to the auth request, if
81
- # you need to set them dynamically. You can also set these options
82
- # in the OmniAuth config :authorize_params option.
83
- #
84
- # /auth/weibo?display=mobile&with_offical_account=1
85
- #
86
78
  def authorize_params
87
79
  super.tap do |params|
88
80
  %w[display with_offical_account forcelogin].each do |v|
@@ -90,7 +82,6 @@ module OmniAuth
90
82
  params[v.to_sym] = request.params[v]
91
83
  end
92
84
  end
93
- # Ensure state parameter is properly set for CSRF protection
94
85
  session['omniauth.state'] = params[:state] = SecureRandom.hex(24)
95
86
  end
96
87
  end
@@ -101,34 +92,6 @@ module OmniAuth
101
92
  end
102
93
  super
103
94
  end
104
-
105
- protected
106
- def build_access_token
107
- params = {
108
- 'client_id' => client.id,
109
- 'client_secret' => client.secret,
110
- 'code' => request.params['code'],
111
- 'grant_type' => 'authorization_code',
112
- 'redirect_uri' => callback_url
113
- }.merge(token_params.to_hash(symbolize_keys: true))
114
- begin
115
- client.get_token(params, deep_symbolize(options.token_params))
116
- rescue ::OAuth2::Error => e
117
- raise OmniAuth::Strategies::OAuth2::Error.new(e)
118
- rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
119
- raise OmniAuth::Strategies::OAuth2::Error.new(e)
120
- end
121
- end
122
-
123
- def callback_phase
124
- super
125
- rescue ::OAuth2::Error => e
126
- fail!(:invalid_credentials, e)
127
- rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
128
- fail!(:timeout, e)
129
- rescue ::SocketError => e
130
- fail!(:failed_to_connect, e)
131
- end
132
95
  end
133
96
  end
134
97
  end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module ScavinWeiboOauth2
3
+ VERSION = "0.5.7"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "scavin-weibo-oauth2/version"
2
+ require 'omniauth/strategies/weibo'
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/omniauth-weibo-oauth2/version', __FILE__)
2
+ require File.expand_path('../lib/scavin-weibo-oauth2/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = "Scavin"
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.name = "scavin-weibo-oauth2"
16
16
  gem.require_paths = ["lib"]
17
- gem.version = OmniAuth::WeiboOauth2::VERSION
17
+ gem.version = OmniAuth::ScavinWeiboOauth2::VERSION
18
18
 
19
19
  gem.add_dependency 'omniauth', '~> 2.0'
20
20
  gem.add_dependency 'omniauth-oauth2', '~> 1.4', '>= 1.4.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scavin-weibo-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scavin
@@ -56,11 +56,15 @@ files:
56
56
  - LICENSE.md
57
57
  - README.md
58
58
  - Rakefile
59
- - lib/omniauth-weibo-oauth2.rb
60
- - lib/omniauth-weibo-oauth2/version.rb
61
59
  - lib/omniauth/.DS_Store
62
60
  - lib/omniauth/strategies/weibo.rb
63
61
  - lib/omniauth/strategies/weibo_post_middleware.rb
62
+ - lib/scavin-weibo-oauth2.rb
63
+ - lib/scavin-weibo-oauth2/version.rb
64
+ - scavin-weibo-oauth2-0.5.3.gem
65
+ - scavin-weibo-oauth2-0.5.4.gem
66
+ - scavin-weibo-oauth2-0.5.5.gem
67
+ - scavin-weibo-oauth2-0.5.6.gem
64
68
  - scavin-weibo-oauth2.gemspec
65
69
  homepage: https://github.com/scavin/omniauth-weibo-oauth2
66
70
  licenses:
@@ -1,5 +0,0 @@
1
- module OmniAuth
2
- module WeiboOauth2
3
- VERSION = "0.5.5"
4
- end
5
- end
@@ -1,2 +0,0 @@
1
- require "omniauth-weibo-oauth2/version"
2
- require 'omniauth/strategies/weibo'