omniauth-douban 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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-douban.gemspec
4
+ gemspec
data/README ADDED
File without changes
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-douban/version"
2
+ require 'omniauth/strategies/douban'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Douban
3
+ VERSION = "1.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,71 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Douban < OmniAuth::Strategies::OAuth
7
+ option :name, 'douban'
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/douban.rb#L15-21
12
+ options.client_options = {
13
+ :access_token_path => '/service/auth/access_token',
14
+ :authorize_path => '/service/auth/authorize',
15
+ :realm => 'OmniAuth',
16
+ :request_token_path => '/service/auth/request_token',
17
+ :site => 'http://www.douban.com',
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
+ # adapted from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/douban.rb#L38-53
29
+ info do
30
+ {
31
+ :nickname => raw_info['db:uid']['$t'],
32
+ :name => raw_info['title']['$t'],
33
+ :location => raw_info['location'] ? raw_info['location']['$t'] : nil,
34
+ :image => raw_info['link'].find{|l| l['@rel'] == 'icon'}['@href'],
35
+ :description => raw_info['content']['$t'],
36
+ :urls => {
37
+ 'Douban' => raw_info['link'].find{|l| l['@rel'] == 'alternate'}['@href'],
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('http://api.douban.com/people/%40me?alt=json').body)
66
+ rescue ::Errno::ETIMEDOUT
67
+ raise ::Timeout::Error
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-douban/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-douban"
7
+ s.version = Omniauth::Douban::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for douban}
12
+ s.description = %q{an omniauth strategy for douban}
13
+
14
+ s.rubyforge_project = "omniauth-douban"
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-douban
3
+ version: !ruby/object:Gem::Version
4
+ hash: -248520920
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: -248520920
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: -248520920
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 douban
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-douban.rb
87
+ - lib/omniauth-douban/version.rb
88
+ - lib/omniauth/strategies/douban.rb
89
+ - omniauth-douban.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-douban
121
+ rubygems_version: 1.8.11
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: an omniauth strategy for douban
125
+ test_files: []
126
+