oauth 0.5.6 → 1.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +504 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +40 -0
- data/LICENSE +19 -17
- data/README.md +390 -0
- data/SECURITY.md +26 -0
- data/lib/oauth/client/action_controller_request.rb +23 -21
- data/lib/oauth/client/em_http.rb +99 -99
- data/lib/oauth/client/helper.rb +83 -82
- data/lib/oauth/client/net_http.rb +112 -105
- data/lib/oauth/client.rb +2 -0
- data/lib/oauth/consumer.rb +147 -133
- data/lib/oauth/errors/error.rb +2 -0
- data/lib/oauth/errors/problem.rb +3 -0
- data/lib/oauth/errors/unauthorized.rb +7 -1
- data/lib/oauth/errors.rb +5 -3
- data/lib/oauth/helper.rb +26 -18
- data/lib/oauth/oauth.rb +6 -4
- data/lib/oauth/oauth_test_helper.rb +6 -4
- data/lib/oauth/request_proxy/action_controller_request.rb +49 -71
- data/lib/oauth/request_proxy/action_dispatch_request.rb +8 -4
- data/lib/oauth/request_proxy/base.rb +136 -132
- data/lib/oauth/request_proxy/curb_request.rb +49 -43
- data/lib/oauth/request_proxy/em_http_request.rb +59 -49
- data/lib/oauth/request_proxy/jabber_request.rb +12 -9
- data/lib/oauth/request_proxy/mock_request.rb +5 -3
- data/lib/oauth/request_proxy/net_http.rb +61 -54
- data/lib/oauth/request_proxy/rack_request.rb +35 -31
- data/lib/oauth/request_proxy/rest_client_request.rb +54 -50
- data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
- data/lib/oauth/request_proxy.rb +7 -4
- data/lib/oauth/server.rb +14 -12
- data/lib/oauth/signature/base.rb +78 -71
- data/lib/oauth/signature/hmac/sha1.rb +16 -10
- data/lib/oauth/signature/hmac/sha256.rb +16 -10
- data/lib/oauth/signature/plaintext.rb +18 -20
- data/lib/oauth/signature/rsa/sha1.rb +46 -38
- data/lib/oauth/signature.rb +8 -5
- data/lib/oauth/token.rb +7 -5
- data/lib/oauth/tokens/access_token.rb +5 -3
- data/lib/oauth/tokens/consumer_token.rb +4 -2
- data/lib/oauth/tokens/request_token.rb +12 -10
- data/lib/oauth/tokens/server_token.rb +2 -1
- data/lib/oauth/tokens/token.rb +2 -0
- data/lib/oauth/version.rb +5 -1
- data/lib/oauth.rb +17 -9
- metadata +105 -98
- data/README.rdoc +0 -88
- data/bin/oauth +0 -11
- data/lib/oauth/cli/authorize_command.rb +0 -71
- data/lib/oauth/cli/base_command.rb +0 -208
- data/lib/oauth/cli/help_command.rb +0 -22
- data/lib/oauth/cli/query_command.rb +0 -25
- data/lib/oauth/cli/sign_command.rb +0 -81
- data/lib/oauth/cli/version_command.rb +0 -7
- data/lib/oauth/cli.rb +0 -56
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -12,67 +12,74 @@ authors:
|
|
12
12
|
- Seth Fitzsimmons
|
13
13
|
- Matt Sanford
|
14
14
|
- Aaron Quint
|
15
|
-
|
15
|
+
- Peter Boling
|
16
|
+
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
|
-
date:
|
19
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: oauth-tty
|
22
23
|
requirement: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.0'
|
24
28
|
- - ">="
|
25
29
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
type: :
|
30
|
+
version: 1.0.1
|
31
|
+
type: :runtime
|
28
32
|
prerelease: false
|
29
33
|
version_requirements: !ruby/object:Gem::Requirement
|
30
34
|
requirements:
|
35
|
+
- - "~>"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.0'
|
31
38
|
- - ">="
|
32
39
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
40
|
+
version: 1.0.1
|
34
41
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
42
|
+
name: snaky_hash
|
36
43
|
requirement: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
|
-
- - "
|
45
|
+
- - "~>"
|
39
46
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
type: :
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
42
49
|
prerelease: false
|
43
50
|
version_requirements: !ruby/object:Gem::Requirement
|
44
51
|
requirements:
|
45
|
-
- - "
|
52
|
+
- - "~>"
|
46
53
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
54
|
+
version: '2.0'
|
48
55
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
56
|
+
name: version_gem
|
50
57
|
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- - "
|
59
|
+
- - "~>"
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
type: :
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
56
63
|
prerelease: false
|
57
64
|
version_requirements: !ruby/object:Gem::Requirement
|
58
65
|
requirements:
|
59
|
-
- - "
|
66
|
+
- - "~>"
|
60
67
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
68
|
+
version: '1.1'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
70
|
+
name: em-http-request
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
72
|
requirements:
|
66
|
-
- - "
|
73
|
+
- - "~>"
|
67
74
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
75
|
+
version: 1.1.7
|
69
76
|
type: :development
|
70
77
|
prerelease: false
|
71
78
|
version_requirements: !ruby/object:Gem::Requirement
|
72
79
|
requirements:
|
73
|
-
- - "
|
80
|
+
- - "~>"
|
74
81
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
82
|
+
version: 1.1.7
|
76
83
|
- !ruby/object:Gem::Dependency
|
77
84
|
name: iconv
|
78
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,21 +95,21 @@ dependencies:
|
|
88
95
|
- !ruby/object:Gem::Version
|
89
96
|
version: '0'
|
90
97
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
98
|
+
name: minitest
|
92
99
|
requirement: !ruby/object:Gem::Requirement
|
93
100
|
requirements:
|
94
101
|
- - "~>"
|
95
102
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
103
|
+
version: 5.15.0
|
97
104
|
type: :development
|
98
105
|
prerelease: false
|
99
106
|
version_requirements: !ruby/object:Gem::Requirement
|
100
107
|
requirements:
|
101
108
|
- - "~>"
|
102
109
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
110
|
+
version: 5.15.0
|
104
111
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
112
|
+
name: mocha
|
106
113
|
requirement: !ruby/object:Gem::Requirement
|
107
114
|
requirements:
|
108
115
|
- - ">="
|
@@ -116,55 +123,49 @@ dependencies:
|
|
116
123
|
- !ruby/object:Gem::Version
|
117
124
|
version: '0'
|
118
125
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
126
|
+
name: rack
|
120
127
|
requirement: !ruby/object:Gem::Requirement
|
121
128
|
requirements:
|
122
|
-
- - "
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.9.12
|
125
|
-
- - "<="
|
129
|
+
- - "~>"
|
126
130
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
131
|
+
version: '2.0'
|
128
132
|
type: :development
|
129
133
|
prerelease: false
|
130
134
|
version_requirements: !ruby/object:Gem::Requirement
|
131
135
|
requirements:
|
132
|
-
- - "
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: 0.9.12
|
135
|
-
- - "<="
|
136
|
+
- - "~>"
|
136
137
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
138
|
+
version: '2.0'
|
138
139
|
- !ruby/object:Gem::Dependency
|
139
|
-
name:
|
140
|
+
name: rack-test
|
140
141
|
requirement: !ruby/object:Gem::Requirement
|
141
142
|
requirements:
|
142
143
|
- - ">="
|
143
144
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0
|
145
|
+
version: '0'
|
145
146
|
type: :development
|
146
147
|
prerelease: false
|
147
148
|
version_requirements: !ruby/object:Gem::Requirement
|
148
149
|
requirements:
|
149
150
|
- - ">="
|
150
151
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0
|
152
|
+
version: '0'
|
152
153
|
- !ruby/object:Gem::Dependency
|
153
|
-
name:
|
154
|
+
name: rake
|
154
155
|
requirement: !ruby/object:Gem::Requirement
|
155
156
|
requirements:
|
156
|
-
- -
|
157
|
+
- - "~>"
|
157
158
|
- !ruby/object:Gem::Version
|
158
|
-
version: 0
|
159
|
+
version: '13.0'
|
159
160
|
type: :development
|
160
161
|
prerelease: false
|
161
162
|
version_requirements: !ruby/object:Gem::Requirement
|
162
163
|
requirements:
|
163
|
-
- -
|
164
|
+
- - "~>"
|
164
165
|
- !ruby/object:Gem::Version
|
165
|
-
version: 0
|
166
|
+
version: '13.0'
|
166
167
|
- !ruby/object:Gem::Dependency
|
167
|
-
name:
|
168
|
+
name: rest-client
|
168
169
|
requirement: !ruby/object:Gem::Requirement
|
169
170
|
requirements:
|
170
171
|
- - ">="
|
@@ -178,83 +179,62 @@ dependencies:
|
|
178
179
|
- !ruby/object:Gem::Version
|
179
180
|
version: '0'
|
180
181
|
- !ruby/object:Gem::Dependency
|
181
|
-
name:
|
182
|
-
requirement: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "<"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '2.0'
|
187
|
-
type: :development
|
188
|
-
prerelease: false
|
189
|
-
version_requirements: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "<"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '2.0'
|
194
|
-
- !ruby/object:Gem::Dependency
|
195
|
-
name: codeclimate-test-reporter
|
182
|
+
name: rubocop-lts
|
196
183
|
requirement: !ruby/object:Gem::Requirement
|
197
184
|
requirements:
|
198
|
-
- - "
|
185
|
+
- - "~>"
|
199
186
|
- !ruby/object:Gem::Version
|
200
|
-
version: '0'
|
187
|
+
version: '18.0'
|
201
188
|
type: :development
|
202
189
|
prerelease: false
|
203
190
|
version_requirements: !ruby/object:Gem::Requirement
|
204
191
|
requirements:
|
205
|
-
- - "
|
192
|
+
- - "~>"
|
206
193
|
- !ruby/object:Gem::Version
|
207
|
-
version: '0'
|
194
|
+
version: '18.0'
|
208
195
|
- !ruby/object:Gem::Dependency
|
209
|
-
name:
|
196
|
+
name: typhoeus
|
210
197
|
requirement: !ruby/object:Gem::Requirement
|
211
198
|
requirements:
|
212
199
|
- - ">="
|
213
200
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
201
|
+
version: 0.1.13
|
215
202
|
type: :development
|
216
203
|
prerelease: false
|
217
204
|
version_requirements: !ruby/object:Gem::Requirement
|
218
205
|
requirements:
|
219
206
|
- - ">="
|
220
207
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
208
|
+
version: 0.1.13
|
222
209
|
- !ruby/object:Gem::Dependency
|
223
|
-
name:
|
210
|
+
name: webmock
|
224
211
|
requirement: !ruby/object:Gem::Requirement
|
225
212
|
requirements:
|
226
|
-
- - "
|
213
|
+
- - "<="
|
227
214
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
215
|
+
version: 3.19.0
|
229
216
|
type: :development
|
230
217
|
prerelease: false
|
231
218
|
version_requirements: !ruby/object:Gem::Requirement
|
232
219
|
requirements:
|
233
|
-
- - "
|
220
|
+
- - "<="
|
234
221
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
236
|
-
description:
|
237
|
-
email: oauth-ruby@
|
238
|
-
executables:
|
239
|
-
- oauth
|
222
|
+
version: 3.19.0
|
223
|
+
description:
|
224
|
+
email: oauth-ruby@googlegroups.com
|
225
|
+
executables: []
|
240
226
|
extensions: []
|
241
227
|
extra_rdoc_files:
|
242
|
-
- LICENSE
|
243
|
-
- README.rdoc
|
244
228
|
- TODO
|
245
229
|
files:
|
230
|
+
- CHANGELOG.md
|
231
|
+
- CODE_OF_CONDUCT.md
|
232
|
+
- CONTRIBUTING.md
|
246
233
|
- LICENSE
|
247
|
-
- README.
|
234
|
+
- README.md
|
235
|
+
- SECURITY.md
|
248
236
|
- TODO
|
249
|
-
- bin/oauth
|
250
237
|
- lib/oauth.rb
|
251
|
-
- lib/oauth/cli.rb
|
252
|
-
- lib/oauth/cli/authorize_command.rb
|
253
|
-
- lib/oauth/cli/base_command.rb
|
254
|
-
- lib/oauth/cli/help_command.rb
|
255
|
-
- lib/oauth/cli/query_command.rb
|
256
|
-
- lib/oauth/cli/sign_command.rb
|
257
|
-
- lib/oauth/cli/version_command.rb
|
258
238
|
- lib/oauth/client.rb
|
259
239
|
- lib/oauth/client/action_controller_request.rb
|
260
240
|
- lib/oauth/client/em_http.rb
|
@@ -298,12 +278,39 @@ homepage: https://github.com/oauth-xx/oauth-ruby
|
|
298
278
|
licenses:
|
299
279
|
- MIT
|
300
280
|
metadata:
|
301
|
-
bug_tracker_uri: https://github.com/oauth-xx/oauth-ruby/issues
|
302
|
-
changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/master/HISTORY
|
303
|
-
documentation_uri: https://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
|
304
281
|
homepage_uri: https://github.com/oauth-xx/oauth-ruby
|
305
|
-
source_code_uri: https://github.com/oauth-xx/oauth-ruby
|
306
|
-
|
282
|
+
source_code_uri: https://github.com/oauth-xx/oauth-ruby/tree/v1.1.0
|
283
|
+
changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/v1.1.0/CHANGELOG.md
|
284
|
+
bug_tracker_uri: https://github.com/oauth-xx/oauth-ruby/issues
|
285
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth/1.1.0
|
286
|
+
wiki_uri: https://github.com/oauth-xx/oauth-ruby/wiki
|
287
|
+
rubygems_mfa_required: 'true'
|
288
|
+
post_install_message: |2
|
289
|
+
|
290
|
+
You have installed oauth version 1.1.0, congratulations!
|
291
|
+
|
292
|
+
Non-commercial support for the 1.x series will end by April, 2025. Please make a plan to upgrade to the next version prior to that date.
|
293
|
+
The only breaking change will be dropped support for Ruby 2.7 and any other versions which will also have reached EOL by then.
|
294
|
+
|
295
|
+
Please see:
|
296
|
+
• https://github.com/oauth-xx/oauth-ruby/blob/main/SECURITY.md
|
297
|
+
|
298
|
+
Note also that I am, and this project is, in the process of leaving Github.
|
299
|
+
I wrote about some of the reasons here:
|
300
|
+
• https://dev.to/galtzo/im-leaving-github-50ba
|
301
|
+
|
302
|
+
If you are a human, please consider a donation as I move toward supporting myself with Open Source work:
|
303
|
+
• https://liberapay.com/pboling
|
304
|
+
• https://ko-fi.com/pboling
|
305
|
+
• https://patreon.com/galtzo
|
306
|
+
|
307
|
+
If you are a corporation, please consider supporting this project, and open source work generally, with a TideLift subscription.
|
308
|
+
• https://tidelift.com/funding/github/rubygems/oauth
|
309
|
+
• Or hire me. I am looking for a job!
|
310
|
+
|
311
|
+
Please report issues, and support the project!
|
312
|
+
|
313
|
+
Thanks, |7eter l-|. l3oling
|
307
314
|
rdoc_options: []
|
308
315
|
require_paths:
|
309
316
|
- lib
|
@@ -311,15 +318,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
311
318
|
requirements:
|
312
319
|
- - ">="
|
313
320
|
- !ruby/object:Gem::Version
|
314
|
-
version: '2.
|
321
|
+
version: '2.7'
|
315
322
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
316
323
|
requirements:
|
317
324
|
- - ">="
|
318
325
|
- !ruby/object:Gem::Version
|
319
326
|
version: '0'
|
320
327
|
requirements: []
|
321
|
-
rubygems_version: 3.
|
322
|
-
signing_key:
|
328
|
+
rubygems_version: 3.3.21
|
329
|
+
signing_key:
|
323
330
|
specification_version: 4
|
324
331
|
summary: OAuth Core Ruby implementation
|
325
332
|
test_files: []
|
data/README.rdoc
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
= Ruby OAuth
|
2
|
-
|
3
|
-
== Status
|
4
|
-
|
5
|
-
{<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.com/github/oauth-xx/oauth-ruby]
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
== What
|
10
|
-
|
11
|
-
This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.
|
12
|
-
|
13
|
-
See the OAuth specs http://oauth.net/core/1.0/
|
14
|
-
|
15
|
-
== Installing
|
16
|
-
|
17
|
-
sudo gem install oauth
|
18
|
-
|
19
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
|
20
|
-
|
21
|
-
== The basics
|
22
|
-
|
23
|
-
This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.
|
24
|
-
|
25
|
-
As a matter of fact it has been pulled out from an OAuth Rails GEM (https://rubygems.org/gems/oauth-plugin https://github.com/pelle/oauth-plugin) which now uses this gem as a dependency.
|
26
|
-
|
27
|
-
== Demonstration of usage
|
28
|
-
|
29
|
-
We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)
|
30
|
-
|
31
|
-
callback_url = "http://127.0.0.1:3000/oauth/callback"
|
32
|
-
|
33
|
-
Create a new `OAuth::Consumer` instance by passing it a configuration hash:
|
34
|
-
|
35
|
-
oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
|
36
|
-
|
37
|
-
Start the process by requesting a token
|
38
|
-
|
39
|
-
request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
|
40
|
-
|
41
|
-
session[:token] = request_token.token
|
42
|
-
session[:token_secret] = request_token.secret
|
43
|
-
redirect_to request_token.authorize_url(:oauth_callback => callback_url)
|
44
|
-
|
45
|
-
When user returns create an access_token
|
46
|
-
|
47
|
-
hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
|
48
|
-
request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
|
49
|
-
access_token = request_token.get_access_token
|
50
|
-
# For 3-legged authorization, flow oauth_verifier is passed as param in callback
|
51
|
-
# access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
|
52
|
-
@photos = access_token.get('/photos.xml')
|
53
|
-
|
54
|
-
Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.
|
55
|
-
|
56
|
-
require 'typhoeus'
|
57
|
-
require 'oauth/request_proxy/typhoeus_request'
|
58
|
-
oauth_params = {:consumer => oauth_consumer, :token => access_token}
|
59
|
-
hydra = Typhoeus::Hydra.new
|
60
|
-
req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
|
61
|
-
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
|
62
|
-
req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
|
63
|
-
hydra.queue(req)
|
64
|
-
hydra.run
|
65
|
-
@response = req.response
|
66
|
-
|
67
|
-
|
68
|
-
== More Information
|
69
|
-
|
70
|
-
* RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
|
71
|
-
* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby
|
72
|
-
|
73
|
-
== How to submit patches
|
74
|
-
|
75
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
|
76
|
-
|
77
|
-
To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
|
78
|
-
|
79
|
-
== License
|
80
|
-
|
81
|
-
This code is free to use under the terms of the MIT license.
|
82
|
-
|
83
|
-
== Contact
|
84
|
-
|
85
|
-
OAuth Ruby has been created and maintained by a large number of talented individuals.
|
86
|
-
The current maintainer is Aaron Quint (quirkey).
|
87
|
-
|
88
|
-
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
|
data/bin/oauth
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative "../lib/oauth"
|
4
|
-
require 'oauth/cli'
|
5
|
-
|
6
|
-
Signal.trap("INT") { puts; exit(1) } # don't dump a backtrace on a ^C
|
7
|
-
|
8
|
-
ARGV << 'help' if ARGV.empty?
|
9
|
-
command = ARGV.shift
|
10
|
-
|
11
|
-
OAuth::CLI.new(STDOUT, STDIN, STDERR, command, ARGV).run
|
@@ -1,71 +0,0 @@
|
|
1
|
-
class OAuth::CLI
|
2
|
-
class AuthorizeCommand < BaseCommand
|
3
|
-
|
4
|
-
def required_options
|
5
|
-
[:uri]
|
6
|
-
end
|
7
|
-
|
8
|
-
def _run
|
9
|
-
request_token = get_request_token
|
10
|
-
|
11
|
-
if request_token.callback_confirmed?
|
12
|
-
puts "Server appears to support OAuth 1.0a; enabling support."
|
13
|
-
options[:version] = "1.0a"
|
14
|
-
end
|
15
|
-
|
16
|
-
puts "Please visit this url to authorize:"
|
17
|
-
puts request_token.authorize_url
|
18
|
-
|
19
|
-
# parameters for OAuth 1.0a
|
20
|
-
oauth_verifier = ask_user_for_verifier
|
21
|
-
|
22
|
-
verbosely_get_access_token(request_token, oauth_verifier)
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_request_token
|
26
|
-
consumer = get_consumer
|
27
|
-
scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
|
28
|
-
consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, scope_options)
|
29
|
-
rescue OAuth::Unauthorized => e
|
30
|
-
alert "A problem occurred while attempting to authorize:"
|
31
|
-
alert e
|
32
|
-
alert e.request.body
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_consumer
|
36
|
-
OAuth::Consumer.new \
|
37
|
-
options[:oauth_consumer_key],
|
38
|
-
options[:oauth_consumer_secret],
|
39
|
-
:access_token_url => options[:access_token_url],
|
40
|
-
:authorize_url => options[:authorize_url],
|
41
|
-
:request_token_url => options[:request_token_url],
|
42
|
-
:scheme => options[:scheme],
|
43
|
-
:http_method => options[:method].to_s.downcase.to_sym
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def ask_user_for_verifier
|
48
|
-
if options[:version] == "1.0a"
|
49
|
-
puts "Please enter the verification code provided by the SP (oauth_verifier):"
|
50
|
-
@stdin.gets.chomp
|
51
|
-
else
|
52
|
-
puts "Press return to continue..."
|
53
|
-
@stdin.gets
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def verbosely_get_access_token(request_token, oauth_verifier)
|
59
|
-
access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
|
60
|
-
|
61
|
-
puts "Response:"
|
62
|
-
access_token.params.each do |k,v|
|
63
|
-
puts " #{k}: #{v}" unless k.is_a?(Symbol)
|
64
|
-
end
|
65
|
-
rescue OAuth::Unauthorized => e
|
66
|
-
alert "A problem occurred while attempting to obtain an access token:"
|
67
|
-
alert e
|
68
|
-
alert e.request.body
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|