omniauth-weibo 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +1 -0
- data/lib/omniauth/strategies/weibo.rb +71 -0
- data/lib/omniauth-weibo/version.rb +5 -0
- data/lib/omniauth-weibo.rb +2 -0
- data/omniauth-weibo.gemspec +28 -0
- metadata +126 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Weibo < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, 'weibo'
|
8
|
+
option :sign_in, true
|
9
|
+
def initialize(*args)
|
10
|
+
super
|
11
|
+
# taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L15-21
|
12
|
+
options.client_options = {
|
13
|
+
:access_token_path => '/oauth/access_token',
|
14
|
+
:authorize_path => '/oauth/authorize',
|
15
|
+
:realm => 'OmniAuth',
|
16
|
+
:request_token_path => '/oauth/request_token',
|
17
|
+
:site => 'http://api.t.sina.com.cn',
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def consumer
|
22
|
+
consumer = ::OAuth::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options)
|
23
|
+
consumer
|
24
|
+
end
|
25
|
+
|
26
|
+
uid { access_token.params[:id] }
|
27
|
+
|
28
|
+
info do
|
29
|
+
{
|
30
|
+
:nickname => raw_info['screen_name'],
|
31
|
+
:name => raw_info['name'],
|
32
|
+
:location => raw_info['location'],
|
33
|
+
:image => raw_info['profile_image_url'],
|
34
|
+
:description => raw_info['description'],
|
35
|
+
:urls => {
|
36
|
+
'Website' => raw_info['url'],
|
37
|
+
'Weibo' => 'http://weibo.com/' + raw_info['id'].to_s,
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
extra do
|
43
|
+
{ :raw_info => raw_info }
|
44
|
+
end
|
45
|
+
|
46
|
+
#taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67
|
47
|
+
def request_phase
|
48
|
+
request_token = consumer.get_request_token(:oauth_callback => callback_url)
|
49
|
+
session['oauth'] ||= {}
|
50
|
+
session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
|
51
|
+
|
52
|
+
if request_token.callback_confirmed?
|
53
|
+
redirect request_token.authorize_url(options[:authorize_params])
|
54
|
+
else
|
55
|
+
redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
|
56
|
+
end
|
57
|
+
|
58
|
+
rescue ::Timeout::Error => e
|
59
|
+
fail!(:timeout, e)
|
60
|
+
rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
|
61
|
+
fail!(:service_unavailable, e)
|
62
|
+
end
|
63
|
+
|
64
|
+
def raw_info
|
65
|
+
@raw_info ||= MultiJson.decode(access_token.get('/account/verify_credentials.json').body)
|
66
|
+
rescue ::Errno::ETIMEDOUT
|
67
|
+
raise ::Timeout::Error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-weibo/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-weibo"
|
7
|
+
s.version = Omniauth::Weibo::VERSION
|
8
|
+
s.authors = ["Scott Ballantyne"]
|
9
|
+
s.email = ["ussballantyne@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{an omniauth strategy for sina weibo}
|
12
|
+
s.description = %q{an omniauth strategy for sina weibo}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-weibo"
|
15
|
+
|
16
|
+
s.add_dependency 'omniauth', '~> 1.0.0.rc2'
|
17
|
+
s.add_dependency 'omniauth-oauth', '~> 1.0.0.rc2'
|
18
|
+
s.add_dependency 'multi_json'
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
# specify any dependencies here; for example:
|
26
|
+
# s.add_development_dependency "rspec"
|
27
|
+
# s.add_runtime_dependency "rest-client"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-weibo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 1642168613
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 2
|
12
|
+
version: 1.0.0.rc2
|
13
|
+
platform: ruby
|
14
|
+
authors:
|
15
|
+
- Scott Ballantyne
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2011-10-29 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: omniauth
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 1642168613
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 0
|
35
|
+
- rc
|
36
|
+
- 2
|
37
|
+
version: 1.0.0.rc2
|
38
|
+
type: :runtime
|
39
|
+
version_requirements: *id001
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: omniauth-oauth
|
42
|
+
prerelease: false
|
43
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 1642168613
|
49
|
+
segments:
|
50
|
+
- 1
|
51
|
+
- 0
|
52
|
+
- 0
|
53
|
+
- rc
|
54
|
+
- 2
|
55
|
+
version: 1.0.0.rc2
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: *id002
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: multi_json
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: *id003
|
72
|
+
description: an omniauth strategy for sina weibo
|
73
|
+
email:
|
74
|
+
- ussballantyne@gmail.com
|
75
|
+
executables: []
|
76
|
+
|
77
|
+
extensions: []
|
78
|
+
|
79
|
+
extra_rdoc_files: []
|
80
|
+
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- Gemfile
|
84
|
+
- README
|
85
|
+
- Rakefile
|
86
|
+
- lib/omniauth-weibo.rb
|
87
|
+
- lib/omniauth-weibo/version.rb
|
88
|
+
- lib/omniauth/strategies/weibo.rb
|
89
|
+
- omniauth-weibo.gemspec
|
90
|
+
homepage: ""
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 25
|
113
|
+
segments:
|
114
|
+
- 1
|
115
|
+
- 3
|
116
|
+
- 1
|
117
|
+
version: 1.3.1
|
118
|
+
requirements: []
|
119
|
+
|
120
|
+
rubyforge_project: omniauth-weibo
|
121
|
+
rubygems_version: 1.8.11
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: an omniauth strategy for sina weibo
|
125
|
+
test_files: []
|
126
|
+
|