oa-oauth 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,5 +37,7 @@ module OmniAuth
37
37
  autoload :Doit, 'omniauth/strategies/doit'
38
38
  autoload :Instapaper, 'omniauth/strategies/instapaper'
39
39
  autoload :TradeMe, 'omniauth/strategies/trade_me'
40
+ autoload :Teambox, 'omniauth/strategies/teambox'
41
+ autoload :Tumblr, 'omniauth/strategies/tumblr'
40
42
  end
41
43
  end
@@ -62,7 +62,7 @@ module OmniAuth
62
62
  fail!(:service_unavailable, e)
63
63
  rescue ::OAuth::Unauthorized => e
64
64
  fail!(:invalid_credentials, e)
65
- rescue ::MultiJson::DecodeError => e
65
+ rescue ::NoMethodError, ::MultiJson::DecodeError => e
66
66
  fail!(:invalid_response, e)
67
67
  end
68
68
 
@@ -0,0 +1,49 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Teambox < OAuth2
7
+ def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
8
+ client_options = {
9
+ :site => "https://teambox.com/",
10
+ :authorize_path => "/oauth/authorize",
11
+ :access_token_path => "/oauth/token"
12
+ }
13
+ super(app, :teambox, client_id, client_secret, client_options, options, &block)
14
+ end
15
+ def request_phase
16
+ options[:scope] ||= "offline_access"
17
+ options[:response_type] ||= 'code'
18
+ super
19
+ end
20
+
21
+ def callback_phase
22
+ options[:grant_type] ||= 'authorization_code'
23
+ super
24
+ end
25
+
26
+ def user_data
27
+ @data ||= MultiJson.decode(@access_token.get("/api/1/account"))
28
+ end
29
+
30
+ def user_info
31
+ {
32
+ 'nickname' => user_data['username'],
33
+ 'name' => user_data['first_name'],
34
+ 'image' => user_data['avatar_url'],
35
+ 'urls' => {}
36
+ }
37
+ end
38
+
39
+ def auth_hash
40
+ OmniAuth::Utils.deep_merge(super, {
41
+ 'uid' => user_data['id'],
42
+ 'user_info' => user_info,
43
+ 'extra' => {'user_hash' => user_data}
44
+ })
45
+ end
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,60 @@
1
+ require 'omniauth/oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ #
6
+ # Authenticate to Tumblr via OAuth and retrieve basic
7
+ # user information.
8
+ #
9
+ # Usage:
10
+ #
11
+ # use OmniAuth::Strategies::Tumblr, 'consumerkey', 'consumersecret'
12
+ #
13
+ class Tumblr < OmniAuth::Strategies::OAuth
14
+ # Initialize the middleware
15
+ #
16
+ # @option options [Boolean, true] :sign_in When true, use the "Sign in with Tumblr" flow instead of the authorization flow.
17
+ def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
18
+ client_options = {
19
+ :site => 'http://www.tumblr.com'
20
+ }
21
+
22
+ client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false
23
+ super(app, :tumblr, consumer_key, consumer_secret, client_options, options)
24
+ end
25
+
26
+ def auth_hash
27
+ OmniAuth::Utils.deep_merge(super, {
28
+ 'uid' => user['name'],
29
+ 'user_info' => user_info,
30
+ 'extra' => { 'user_hash' => user }
31
+ })
32
+ end
33
+
34
+ def user_info
35
+ {
36
+ 'nickname' => user['name'],
37
+ 'name' => user['title'],
38
+ 'image' => user['avatar_url'],
39
+ 'urls' => {
40
+ 'website' => user['url'],
41
+ }
42
+ }
43
+ end
44
+
45
+ def user
46
+ tumblelogs = user_hash['tumblr']['tumblelog']
47
+ if tumblelogs.kind_of?(Array)
48
+ @user ||= tumblelogs[0]
49
+ else
50
+ @user ||= tumblelogs
51
+ end
52
+ end
53
+
54
+ def user_hash
55
+ url = "http://www.tumblr.com/api/authenticate"
56
+ @user_hash ||= Hash.from_xml(@access_token.get(url).body)
57
+ end
58
+ end
59
+ end
60
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-oauth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-05 00:00:00 -05:00
13
+ date: 2011-04-16 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.2.1
23
+ version: 0.2.2
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: *id001
@@ -58,19 +58,30 @@ dependencies:
58
58
  prerelease: false
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: oauth2
61
+ name: faraday
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 0.2.0
67
+ version: 0.6.1
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
72
- name: rake
72
+ name: oauth2
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.3.0
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ requirement: &id007 !ruby/object:Gem::Requirement
74
85
  none: false
75
86
  requirements:
76
87
  - - ">="
@@ -78,10 +89,10 @@ dependencies:
78
89
  version: "0"
79
90
  type: :development
80
91
  prerelease: false
81
- version_requirements: *id006
92
+ version_requirements: *id007
82
93
  - !ruby/object:Gem::Dependency
83
94
  name: mg
84
- requirement: &id007 !ruby/object:Gem::Requirement
95
+ requirement: &id008 !ruby/object:Gem::Requirement
85
96
  none: false
86
97
  requirements:
87
98
  - - ~>
@@ -89,10 +100,10 @@ dependencies:
89
100
  version: 0.0.8
90
101
  type: :development
91
102
  prerelease: false
92
- version_requirements: *id007
103
+ version_requirements: *id008
93
104
  - !ruby/object:Gem::Dependency
94
105
  name: rspec
95
- requirement: &id008 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
96
107
  none: false
97
108
  requirements:
98
109
  - - ~>
@@ -100,10 +111,10 @@ dependencies:
100
111
  version: 1.3.0
101
112
  type: :development
102
113
  prerelease: false
103
- version_requirements: *id008
114
+ version_requirements: *id009
104
115
  - !ruby/object:Gem::Dependency
105
116
  name: webmock
106
- requirement: &id009 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
107
118
  none: false
108
119
  requirements:
109
120
  - - ~>
@@ -111,10 +122,10 @@ dependencies:
111
122
  version: 1.3.4
112
123
  type: :development
113
124
  prerelease: false
114
- version_requirements: *id009
125
+ version_requirements: *id010
115
126
  - !ruby/object:Gem::Dependency
116
127
  name: rack-test
117
- requirement: &id010 !ruby/object:Gem::Requirement
128
+ requirement: &id011 !ruby/object:Gem::Requirement
118
129
  none: false
119
130
  requirements:
120
131
  - - ~>
@@ -122,21 +133,21 @@ dependencies:
122
133
  version: 0.5.4
123
134
  type: :development
124
135
  prerelease: false
125
- version_requirements: *id010
136
+ version_requirements: *id011
126
137
  - !ruby/object:Gem::Dependency
127
- name: json
128
- requirement: &id011 !ruby/object:Gem::Requirement
138
+ name: json_pure
139
+ requirement: &id012 !ruby/object:Gem::Requirement
129
140
  none: false
130
141
  requirements:
131
142
  - - ~>
132
143
  - !ruby/object:Gem::Version
133
- version: 1.4.3
144
+ version: 1.5.1
134
145
  type: :development
135
146
  prerelease: false
136
- version_requirements: *id011
147
+ version_requirements: *id012
137
148
  - !ruby/object:Gem::Dependency
138
149
  name: evernote
139
- requirement: &id012 !ruby/object:Gem::Requirement
150
+ requirement: &id013 !ruby/object:Gem::Requirement
140
151
  none: false
141
152
  requirements:
142
153
  - - ~>
@@ -144,7 +155,7 @@ dependencies:
144
155
  version: 0.9.0
145
156
  type: :development
146
157
  prerelease: false
147
- version_requirements: *id012
158
+ version_requirements: *id013
148
159
  description: OAuth strategies for OmniAuth.
149
160
  email: michael@intridea.com
150
161
  executables: []
@@ -181,9 +192,11 @@ files:
181
192
  - lib/omniauth/strategies/salesforce.rb
182
193
  - lib/omniauth/strategies/smug_mug.rb
183
194
  - lib/omniauth/strategies/sound_cloud.rb
195
+ - lib/omniauth/strategies/teambox.rb
184
196
  - lib/omniauth/strategies/thirty_seven_signals.rb
185
197
  - lib/omniauth/strategies/trade_me.rb
186
198
  - lib/omniauth/strategies/trip_it.rb
199
+ - lib/omniauth/strategies/tumblr.rb
187
200
  - lib/omniauth/strategies/twitter.rb
188
201
  - lib/omniauth/strategies/type_pad.rb
189
202
  - lib/omniauth/strategies/vimeo.rb
@@ -206,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
219
  requirements:
207
220
  - - ">="
208
221
  - !ruby/object:Gem::Version
209
- hash: -1141434774696898432
222
+ hash: -58406961140861733
210
223
  segments:
211
224
  - 0
212
225
  version: "0"
@@ -215,14 +228,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
228
  requirements:
216
229
  - - ">="
217
230
  - !ruby/object:Gem::Version
218
- hash: -1141434774696898432
231
+ hash: -58406961140861733
219
232
  segments:
220
233
  - 0
221
234
  version: "0"
222
235
  requirements: []
223
236
 
224
237
  rubyforge_project:
225
- rubygems_version: 1.5.0
238
+ rubygems_version: 1.6.2
226
239
  signing_key:
227
240
  specification_version: 3
228
241
  summary: OAuth strategies for OmniAuth.