omniauth-tsohu 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-tsohu.gemspec
4
+ gemspec
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,70 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Tsohu < OmniAuth::Strategies::OAuth
7
+ option :name, 'tsohu'
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/tqq.rb#L15-24
12
+ options.client_options = {
13
+ :access_token_path => '/oauth/access_token',
14
+ :authorize_path => '/oauth/authorize',
15
+ :scheme => :header,
16
+ :site => 'http://api.t.sohu.com',
17
+ :request_token_path => '/oauth/request_token',
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
+ 'Tsohu' => raw_info['url']
37
+ }
38
+ }
39
+ end
40
+
41
+ extra do
42
+ { :raw_info => raw_info }
43
+ end
44
+
45
+ #taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67
46
+ def request_phase
47
+ request_token = consumer.get_request_token(:oauth_callback => callback_url)
48
+ session['oauth'] ||= {}
49
+ session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
50
+
51
+ if request_token.callback_confirmed?
52
+ redirect request_token.authorize_url(options[:authorize_params])
53
+ else
54
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
55
+ end
56
+
57
+ rescue ::Timeout::Error => e
58
+ fail!(:timeout, e)
59
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
60
+ fail!(:service_unavailable, e)
61
+ end
62
+
63
+ def raw_info
64
+ @raw_info ||= MultiJson.decode(access_token.get('http://api.t.sohu.com/account/verify_credentials.json').body)
65
+ rescue ::Errno::ETIMEDOUT
66
+ raise ::Timeout::Error
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Tsohu
3
+ VERSION = "1.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-tsohu/version"
2
+ require 'omniauth/strategies/tsohu'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-tsohu/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-tsohu"
7
+ s.version = Omniauth::Tsohu::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for sohu weibo}
12
+ s.description = %q{an omniauth strategy for sohu weibo}
13
+
14
+ s.rubyforge_project = "omniauth-tsohu"
15
+ s.add_dependency 'omniauth', '~> 1.0.0.rc2'
16
+ s.add_dependency 'omniauth-oauth', '~> 1.0.0.rc2'
17
+ s.add_dependency 'multi_json'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ # s.add_runtime_dependency "rest-client"
27
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-tsohu
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1733402975
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: 1733402975
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: 1733402975
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 sohu 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-tsohu.rb
87
+ - lib/omniauth-tsohu/version.rb
88
+ - lib/omniauth/strategies/tsohu.rb
89
+ - omniauth-tsohu.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-tsohu
121
+ rubygems_version: 1.8.11
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: an omniauth strategy for sohu weibo
125
+ test_files: []
126
+