proletarian-oauth 0.3.2
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.
- data/History.txt +48 -0
- data/License.txt +20 -0
- data/Manifest.txt +71 -0
- data/README.rdoc +73 -0
- data/Rakefile +34 -0
- data/TODO +14 -0
- data/bin/oauth +5 -0
- data/lib/oauth/cli.rb +130 -0
- data/lib/oauth/client/action_controller_request.rb +52 -0
- data/lib/oauth/client/helper.rb +75 -0
- data/lib/oauth/client/net_http.rb +75 -0
- data/lib/oauth/client.rb +4 -0
- data/lib/oauth/consumer.rb +246 -0
- data/lib/oauth/helper.rb +17 -0
- data/lib/oauth/oauth_test_helper.rb +26 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +62 -0
- data/lib/oauth/request_proxy/base.rb +107 -0
- data/lib/oauth/request_proxy/jabber_request.rb +42 -0
- data/lib/oauth/request_proxy/mock_request.rb +36 -0
- data/lib/oauth/request_proxy/net_http.rb +65 -0
- data/lib/oauth/request_proxy/rack_request.rb +40 -0
- data/lib/oauth/request_proxy.rb +24 -0
- data/lib/oauth/server.rb +68 -0
- data/lib/oauth/signature/base.rb +89 -0
- data/lib/oauth/signature/hmac/base.rb +12 -0
- data/lib/oauth/signature/hmac/md5.rb +9 -0
- data/lib/oauth/signature/hmac/rmd160.rb +9 -0
- data/lib/oauth/signature/hmac/sha1.rb +10 -0
- data/lib/oauth/signature/hmac/sha2.rb +9 -0
- data/lib/oauth/signature/md5.rb +13 -0
- data/lib/oauth/signature/plaintext.rb +23 -0
- data/lib/oauth/signature/rsa/sha1.rb +44 -0
- data/lib/oauth/signature/sha1.rb +13 -0
- data/lib/oauth/signature.rb +28 -0
- data/lib/oauth/token.rb +137 -0
- data/lib/oauth/version.rb +3 -0
- data/lib/oauth.rb +3 -0
- data/oauth.gemspec +43 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/cases/oauth_case.rb +19 -0
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +62 -0
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +88 -0
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +86 -0
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +77 -0
- data/test/keys/rsa.cert +11 -0
- data/test/keys/rsa.pem +16 -0
- data/test/test_action_controller_request_proxy.rb +28 -0
- data/test/test_consumer.rb +328 -0
- data/test/test_helper.rb +15 -0
- data/test/test_hmac_sha1.rb +21 -0
- data/test/test_net_http_client.rb +169 -0
- data/test/test_net_http_request_proxy.rb +38 -0
- data/test/test_rack_request_proxy.rb +40 -0
- data/test/test_rsa_sha1.rb +59 -0
- data/test/test_server.rb +40 -0
- data/test/test_signature.rb +11 -0
- data/test/test_signature_base.rb +32 -0
- data/test/test_signature_plain_text.rb +31 -0
- data/test/test_token.rb +14 -0
- data/website/index.html +87 -0
- data/website/index.txt +73 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +177 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/consumer'
|
3
|
+
require 'oauth/signature/rsa/sha1'
|
4
|
+
|
5
|
+
class TestSignatureRsaSha1 < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@request = Net::HTTP::Get.new('/photos?file=vacaction.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&oauth_signature_method=RSA-SHA1')
|
9
|
+
|
10
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03', OpenSSL::PKey::RSA.new(IO.read(File.dirname(__FILE__) + "/keys/rsa.pem")))
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_that_rsa_sha1_implements_rsa_sha1
|
15
|
+
assert OAuth::Signature.available_methods.include?('rsa-sha1')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_base_string
|
19
|
+
sbs = OAuth::Signature.signature_base_string(@request, { :consumer => @consumer,
|
20
|
+
:uri => 'http://photos.example.net/photos' } )
|
21
|
+
|
22
|
+
assert_equal 'GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacaction.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3D13917289812797014437%26oauth_signature_method%3DRSA-SHA1%26oauth_timestamp%3D1196666512%26oauth_version%3D1.0%26size%3Doriginal', sbs
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature
|
26
|
+
signature = OAuth::Signature.sign(@request, { :consumer => @consumer,
|
27
|
+
:uri => 'http://photos.example.net/photos' } )
|
28
|
+
|
29
|
+
assert_equal 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=', signature
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_using_private_key_file
|
34
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03',nil)
|
35
|
+
|
36
|
+
signature = OAuth::Signature.sign(@request, { :consumer => @consumer,
|
37
|
+
:private_key_file=>File.dirname(__FILE__) + "/keys/rsa.pem",
|
38
|
+
:uri => 'http://photos.example.net/photos' } )
|
39
|
+
|
40
|
+
assert_equal 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=', signature
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_that_get_request_from_oauth_test_cases_verifies_signature
|
44
|
+
@request = Net::HTTP::Get.new('/photos?oauth_signature_method=RSA-SHA1&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&file=vacaction.jpg&size=original&oauth_signature=jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D')
|
45
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03',OpenSSL::X509::Certificate.new(IO.read(File.dirname(__FILE__) + "/keys/rsa.cert")))
|
46
|
+
|
47
|
+
assert OAuth::Signature.verify(@request, { :consumer => @consumer,
|
48
|
+
:uri => 'http://photos.example.net/photos' } )
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_that_get_request_from_oauth_test_cases_verifies_signature_with_pem
|
53
|
+
@request = Net::HTTP::Get.new('/photos?oauth_signature_method=RSA-SHA1&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&file=vacaction.jpg&size=original&oauth_signature=jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D')
|
54
|
+
assert OAuth::Signature.verify(@request, { :consumer => @consumer,
|
55
|
+
:uri => 'http://photos.example.net/photos' } )
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/test/test_server.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'oauth/server'
|
3
|
+
class ServerTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@server=OAuth::Server.new "http://test.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_default_paths
|
9
|
+
assert_equal "/oauth/request_token",@server.request_token_path
|
10
|
+
assert_equal "/oauth/authorize",@server.authorize_path
|
11
|
+
assert_equal "/oauth/access_token",@server.access_token_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_default_urls
|
15
|
+
assert_equal "http://test.com/oauth/request_token",@server.request_token_url
|
16
|
+
assert_equal "http://test.com/oauth/authorize",@server.authorize_url
|
17
|
+
assert_equal "http://test.com/oauth/access_token",@server.access_token_url
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_generate_consumer_credentials
|
21
|
+
consumer=@server.generate_consumer_credentials
|
22
|
+
assert_not_nil consumer.key
|
23
|
+
assert_not_nil consumer.secret
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_consumer
|
27
|
+
@consumer=@server.create_consumer
|
28
|
+
assert_not_nil @consumer
|
29
|
+
assert_not_nil @consumer.key
|
30
|
+
assert_not_nil @consumer.secret
|
31
|
+
assert_equal "http://test.com",@consumer.site
|
32
|
+
assert_equal "/oauth/request_token",@consumer.request_token_path
|
33
|
+
assert_equal "/oauth/authorize",@consumer.authorize_path
|
34
|
+
assert_equal "/oauth/access_token",@consumer.access_token_path
|
35
|
+
assert_equal "http://test.com/oauth/request_token",@consumer.request_token_url
|
36
|
+
assert_equal "http://test.com/oauth/authorize",@consumer.authorize_url
|
37
|
+
assert_equal "http://test.com/oauth/access_token",@consumer.access_token_url
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/signature/base'
|
3
|
+
require 'net/http'
|
4
|
+
class SignatureBaseTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_that_initialize_requires_one_request_argument
|
7
|
+
assert_raises ArgumentError do
|
8
|
+
OAuth::Signature::Base.new()
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_that_initialize_requires_a_valid_request_argument
|
13
|
+
request = nil
|
14
|
+
assert_raises TypeError do
|
15
|
+
OAuth::Signature::Base.new(request) { |token|
|
16
|
+
# just a stub
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_that_initialize_succeeds_when_the_request_proxy_is_valid
|
22
|
+
# this isn't quite valid, but it will do.
|
23
|
+
raw_request = Net::HTTP::Get.new('/test')
|
24
|
+
request = OAuth::RequestProxy.proxy(raw_request)
|
25
|
+
assert_nothing_raised do
|
26
|
+
OAuth::Signature::Base.new(request) { |token|
|
27
|
+
# just a stub
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/signature/plaintext'
|
3
|
+
|
4
|
+
class TestSignaturePlaintext < Test::Unit::TestCase
|
5
|
+
def test_that_plaintext_implements_plaintext
|
6
|
+
assert OAuth::Signature.available_methods.include?('plaintext')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature
|
10
|
+
request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
|
11
|
+
|
12
|
+
consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
|
13
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', nil)
|
14
|
+
|
15
|
+
assert OAuth::Signature.verify(request, { :consumer => consumer,
|
16
|
+
:token => token,
|
17
|
+
:uri => 'http://photos.example.net/photos' } )
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_part_two
|
21
|
+
request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26pfkkdhi9sl3r4s00&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
|
22
|
+
|
23
|
+
consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
|
24
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
|
25
|
+
|
26
|
+
assert OAuth::Signature.verify(request, { :consumer => consumer,
|
27
|
+
:token => token,
|
28
|
+
:uri => 'http://photos.example.net/photos' } )
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/test/test_token.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/token'
|
3
|
+
|
4
|
+
class TestToken < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_token_constructor_produces_valid_token
|
10
|
+
token = OAuth::Token.new('xyz', '123')
|
11
|
+
assert_equal 'xyz', token.token
|
12
|
+
assert_equal '123', token.secret
|
13
|
+
end
|
14
|
+
end
|
data/website/index.html
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
Ruby OAuth GEM
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
|
33
|
+
<h1>Ruby OAuth GEM</h1>
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oauth"; return false'>
|
35
|
+
<p>Get Version</p>
|
36
|
+
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.0</a>
|
37
|
+
</div>
|
38
|
+
<h2>What</h2>
|
39
|
+
<p>This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.</p>
|
40
|
+
<p>See the <a href="http://oauth.net/core/1.0/">OAuth specs</a></p>
|
41
|
+
<h2>Installing</h2>
|
42
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">oauth</span></pre></p>
|
43
|
+
<p>You can also install it from the <a href="http://rubyforge.org/projects/oauth/">oauth rubyforge project</a>.</p>
|
44
|
+
<p>The source code is now hosted on the <a href="http://github.com/pelle/oauth/tree/master">OAuth GitHub Project</a></p>
|
45
|
+
<h2>The basics</h2>
|
46
|
+
<p>This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is <span class="caps">NOT</span> a Rails plugin, but could easily be used for the foundation for such a Rails plugin.</p>
|
47
|
+
<p>As a matter of fact it has been pulled out from an <a href="http://code.google.com/p/oauth-plugin/">OAuth Rails Plugin</a> which now requires this <span class="caps">GEM</span>.</p>
|
48
|
+
<h2>Demonstration of usage</h2>
|
49
|
+
<p>Create a new consumer instance by passing it a configuration hash:</p>
|
50
|
+
<pre><code>@consumer=OAuth::Consumer.new( "key","secret", {
|
51
|
+
:site=>"https://agree2"
|
52
|
+
})</code></pre>
|
53
|
+
<p>Start the process by requesting a token</p>
|
54
|
+
<pre><code>@request_token=@consumer.get_request_token
|
55
|
+
session[:request_token]=@request_token
|
56
|
+
redirect_to @request_token.authorize_url</code></pre>
|
57
|
+
<p>When user returns create an access_token</p>
|
58
|
+
<pre><code>@access_token=@request_token.get_access_token
|
59
|
+
@photos=@access_token.get('/photos.xml')</code></pre>
|
60
|
+
<p>For more detailed instructions I have written this <a href="http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby">OAuth Client Tutorial</a> and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider.</p>
|
61
|
+
<p>Finally be sure to check out the <a href="http://oauth.rubyforge.org/rdoc/">OAuth RDoc Manual</a>.</p>
|
62
|
+
<h2>Documentation Wiki</h2>
|
63
|
+
<p>There is some documentation on the Google Code project for the <a href="http://code.google.com/p/oauth-plugin/">OAuth Rails Plugin</a> :</p>
|
64
|
+
<ul>
|
65
|
+
<li><a href="http://code.google.com/p/oauth-plugin/wiki/RequestToken">RequestToken</a></li>
|
66
|
+
<li><a href="http://code.google.com/p/oauth-plugin/wiki/AccessToken">AccessToken</a></li>
|
67
|
+
</ul>
|
68
|
+
<h2>Forum</h2>
|
69
|
+
<p><a href="http://groups.google.com/group/oauth-ruby">http://groups.google.com/group/oauth-ruby</a></p>
|
70
|
+
<h2>How to submit patches</h2>
|
71
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a>.</p>
|
72
|
+
<p>The source code is now hosted on the <a href="http://github.com/pelle/oauth/tree/master">OAuth GitHub Project</a></p>
|
73
|
+
<p>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.</p>
|
74
|
+
<h2>License</h2>
|
75
|
+
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
76
|
+
<h2>Contact</h2>
|
77
|
+
<p>Comments are welcome. Send an email to <a href="mailto:pelleb@gmail.com">Pelle Braendgaard</a> email via the <a href="http://groups.google.com/group/oauth-ruby">OAuth Ruby mailing list</a></p>
|
78
|
+
<p class="coda">
|
79
|
+
<a href="FIXME email">FIXME full name</a>, 9th September 2008<br>
|
80
|
+
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
81
|
+
</p>
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
85
|
+
|
86
|
+
</body>
|
87
|
+
</html>
|
data/website/index.txt
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
h1. Ruby OAuth GEM
|
2
|
+
|
3
|
+
h2. What
|
4
|
+
|
5
|
+
This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.
|
6
|
+
|
7
|
+
See the "OAuth specs":http://oauth.net/core/1.0/
|
8
|
+
|
9
|
+
h2. Installing
|
10
|
+
|
11
|
+
<pre syntax="ruby">sudo gem install oauth</pre>
|
12
|
+
|
13
|
+
You can also install it from the "oauth rubyforge project":http://rubyforge.org/projects/oauth/.
|
14
|
+
|
15
|
+
The source code is now hosted on the "OAuth GitHub Project":http://github.com/pelle/oauth/tree/master
|
16
|
+
|
17
|
+
h2. The basics
|
18
|
+
|
19
|
+
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.
|
20
|
+
|
21
|
+
As a matter of fact it has been pulled out from an "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ which now requires this GEM.
|
22
|
+
|
23
|
+
h2. Demonstration of usage
|
24
|
+
|
25
|
+
Create a new consumer instance by passing it a configuration hash:
|
26
|
+
|
27
|
+
<pre><code>@consumer=OAuth::Consumer.new( "key","secret", {
|
28
|
+
:site=>"https://agree2"
|
29
|
+
})</code></pre>
|
30
|
+
|
31
|
+
Start the process by requesting a token
|
32
|
+
|
33
|
+
<pre><code>@request_token=@consumer.get_request_token
|
34
|
+
session[:request_token]=@request_token
|
35
|
+
redirect_to @request_token.authorize_url</code></pre>
|
36
|
+
|
37
|
+
When user returns create an access_token
|
38
|
+
|
39
|
+
<pre><code>@access_token=@request_token.get_access_token
|
40
|
+
@photos=@access_token.get('/photos.xml')</code></pre>
|
41
|
+
|
42
|
+
For more detailed instructions I have written this "OAuth Client Tutorial":http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider.
|
43
|
+
|
44
|
+
Finally be sure to check out the "OAuth RDoc Manual":http://oauth.rubyforge.org/rdoc/.
|
45
|
+
|
46
|
+
h2. Documentation Wiki
|
47
|
+
|
48
|
+
There is some documentation on the Google Code project for the "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ :
|
49
|
+
|
50
|
+
* "RequestToken":http://code.google.com/p/oauth-plugin/wiki/RequestToken
|
51
|
+
* "AccessToken":http://code.google.com/p/oauth-plugin/wiki/AccessToken
|
52
|
+
|
53
|
+
h2. Forum
|
54
|
+
|
55
|
+
"http://groups.google.com/group/oauth-ruby":http://groups.google.com/group/oauth-ruby
|
56
|
+
|
57
|
+
|
58
|
+
h2. How to submit patches
|
59
|
+
|
60
|
+
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/.
|
61
|
+
|
62
|
+
The source code is now hosted on the "OAuth GitHub Project":http://github.com/pelle/oauth/tree/master
|
63
|
+
|
64
|
+
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.
|
65
|
+
|
66
|
+
h2. License
|
67
|
+
|
68
|
+
This code is free to use under the terms of the MIT license.
|
69
|
+
|
70
|
+
h2. Contact
|
71
|
+
|
72
|
+
Comments are welcome. Send an email to "Pelle Braendgaard":mailto:pelleb@gmail.com email via the "OAuth Ruby mailing list":http://groups.google.com/group/oauth-ruby
|
73
|
+
|