omniauth-tudou 1.0.0.rc2

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.
@@ -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-tudou.gemspec
4
+ gemspec
data/README ADDED
File without changes
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-tudou/version"
2
+ require "omniauth/strategies/tudou"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Tudou
3
+ VERSION = "1.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,67 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Tudou < OmniAuth::Strategies::OAuth
7
+ option :name, 'tudou'
8
+ def initialize(*args)
9
+ super
10
+ # taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L15-21
11
+ options.client_options = {
12
+ :access_token_path => '/auth/access_token.oauth',
13
+ :authorize_path => '/auth/authorize.oauth',
14
+ :realm => 'OmniAuth',
15
+ :request_token_path => '/auth/request_token.oauth',
16
+ :site => 'http://api.tudou.com/',
17
+ }
18
+ end
19
+
20
+ def consumer
21
+ consumer = ::OAuth::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options)
22
+ consumer
23
+ end
24
+
25
+ uid { raw_info['userId'] }
26
+
27
+ info do
28
+ {
29
+ :nickname => raw_info['nickName'],
30
+ :name => raw_info['nickName'],
31
+ :image => raw_info['userPicUrl'],
32
+ :urls => {
33
+ 'Tudou' => 'http://www.tudou.com/home/' + raw_info['userName']
34
+ }
35
+ }
36
+ end
37
+
38
+ extra do
39
+ { :raw_info => raw_info }
40
+ end
41
+
42
+ #taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67
43
+ def request_phase
44
+ request_token = consumer.get_request_token(:oauth_callback => callback_url)
45
+ session['oauth'] ||= {}
46
+ session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
47
+
48
+ if request_token.callback_confirmed?
49
+ redirect request_token.authorize_url(options[:authorize_params])
50
+ else
51
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
52
+ end
53
+
54
+ rescue ::Timeout::Error => e
55
+ fail!(:timeout, e)
56
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
57
+ fail!(:service_unavailable, e)
58
+ end
59
+
60
+ def raw_info
61
+ @raw_info ||= MultiJson.decode(access_token.get('http://api.tudou.com/auth/verify_credentials.oauth').body)
62
+ rescue ::Errno::ETIMEDOUT
63
+ raise ::Timeout::Error
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-tudou/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-tudou"
7
+ s.version = Omniauth::Tudou::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for tudou}
12
+ s.description = %q{an omniauth strategy for tudou}
13
+
14
+ s.rubyforge_project = "omniauth-tudou"
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-tudou
3
+ version: !ruby/object:Gem::Version
4
+ hash: -1984635056
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-30 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: -1984635056
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: -1984635056
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 tudou
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-tudou.rb
87
+ - lib/omniauth-tudou/version.rb
88
+ - lib/omniauth/strategies/tudou.rb
89
+ - omniauth-tudou.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-tudou
121
+ rubygems_version: 1.8.11
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: an omniauth strategy for tudou
125
+ test_files: []
126
+