camping-oauth 1.0.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.
Files changed (102) hide show
  1. data/README +3 -0
  2. data/doc/classes/CampingOAuthConsumer.html +145 -0
  3. data/doc/classes/CampingOAuthConsumer.src/M000041.html +19 -0
  4. data/doc/classes/CampingOAuthConsumer/Controllers.html +116 -0
  5. data/doc/classes/CampingOAuthConsumer/Controllers/AccessToken.html +137 -0
  6. data/doc/classes/CampingOAuthConsumer/Controllers/AccessToken.src/M000051.html +32 -0
  7. data/doc/classes/CampingOAuthConsumer/Controllers/AccessTokenAuthorized.html +137 -0
  8. data/doc/classes/CampingOAuthConsumer/Controllers/AccessTokenAuthorized.src/M000050.html +20 -0
  9. data/doc/classes/CampingOAuthConsumer/Controllers/AuthorizeToken.html +137 -0
  10. data/doc/classes/CampingOAuthConsumer/Controllers/AuthorizeToken.src/M000048.html +24 -0
  11. data/doc/classes/CampingOAuthConsumer/Controllers/GetTimeNow.html +137 -0
  12. data/doc/classes/CampingOAuthConsumer/Controllers/GetTimeNow.src/M000049.html +28 -0
  13. data/doc/classes/CampingOAuthConsumer/Controllers/Index.html +137 -0
  14. data/doc/classes/CampingOAuthConsumer/Controllers/Index.src/M000046.html +18 -0
  15. data/doc/classes/CampingOAuthConsumer/Controllers/RequestToken.html +137 -0
  16. data/doc/classes/CampingOAuthConsumer/Controllers/RequestToken.src/M000047.html +24 -0
  17. data/doc/classes/CampingOAuthConsumer/Views.html +176 -0
  18. data/doc/classes/CampingOAuthConsumer/Views.src/M000042.html +42 -0
  19. data/doc/classes/CampingOAuthConsumer/Views.src/M000043.html +41 -0
  20. data/doc/classes/CampingOAuthConsumer/Views.src/M000044.html +18 -0
  21. data/doc/classes/CampingOAuthConsumer/Views.src/M000045.html +19 -0
  22. data/doc/classes/CampingOAuthProvider.html +149 -0
  23. data/doc/classes/CampingOAuthProvider.src/M000052.html +23 -0
  24. data/doc/classes/CampingOAuthProvider/Controllers.html +113 -0
  25. data/doc/classes/CampingOAuthProvider/Controllers/APITimeNow.html +137 -0
  26. data/doc/classes/CampingOAuthProvider/Controllers/APITimeNow.src/M000058.html +23 -0
  27. data/doc/classes/CampingOAuthProvider/Controllers/Index.html +137 -0
  28. data/doc/classes/CampingOAuthProvider/Controllers/Index.src/M000055.html +18 -0
  29. data/doc/classes/CampingOAuthProvider/Controllers/Login.html +152 -0
  30. data/doc/classes/CampingOAuthProvider/Controllers/Login.src/M000056.html +18 -0
  31. data/doc/classes/CampingOAuthProvider/Controllers/Login.src/M000057.html +33 -0
  32. data/doc/classes/CampingOAuthProvider/Helpers.html +112 -0
  33. data/doc/classes/CampingOAuthProvider/Models.html +119 -0
  34. data/doc/classes/CampingOAuthProvider/Models/CreateUserSchema.html +152 -0
  35. data/doc/classes/CampingOAuthProvider/Models/CreateUserSchema.src/M000059.html +26 -0
  36. data/doc/classes/CampingOAuthProvider/Models/CreateUserSchema.src/M000060.html +19 -0
  37. data/doc/classes/CampingOAuthProvider/Models/User.html +111 -0
  38. data/doc/classes/CampingOAuthProvider/Views.html +146 -0
  39. data/doc/classes/CampingOAuthProvider/Views.src/M000053.html +19 -0
  40. data/doc/classes/CampingOAuthProvider/Views.src/M000054.html +27 -0
  41. data/doc/classes/OAuth.html +107 -0
  42. data/doc/classes/OAuth/RequestProxy.html +112 -0
  43. data/doc/classes/OAuth/RequestProxy/Base.html +153 -0
  44. data/doc/classes/OAuth/RequestProxy/Base.src/M000039.html +28 -0
  45. data/doc/classes/OAuth/RequestProxy/Base.src/M000040.html +28 -0
  46. data/doc/classes/OAuth/RequestProxy/RackRequest.html +143 -0
  47. data/doc/classes/OAuth/RequestProxy/RackRequest.src/M000039.html +18 -0
  48. data/doc/classes/OAuthCampingPlugin.html +188 -0
  49. data/doc/classes/OAuthCampingPlugin.src/M000001.html +18 -0
  50. data/doc/classes/OAuthCampingPlugin.src/M000002.html +18 -0
  51. data/doc/classes/OAuthCampingPlugin.src/M000003.html +17 -0
  52. data/doc/classes/OAuthCampingPlugin/Controllers.html +191 -0
  53. data/doc/classes/OAuthCampingPlugin/Controllers.src/M000024.html +18 -0
  54. data/doc/classes/OAuthCampingPlugin/Controllers.src/M000025.html +26 -0
  55. data/doc/classes/OAuthCampingPlugin/Filters.html +161 -0
  56. data/doc/classes/OAuthCampingPlugin/Filters.src/M000034.html +34 -0
  57. data/doc/classes/OAuthCampingPlugin/Helpers.html +283 -0
  58. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000026.html +18 -0
  59. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000027.html +19 -0
  60. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000028.html +20 -0
  61. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000029.html +20 -0
  62. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000030.html +18 -0
  63. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000031.html +18 -0
  64. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000032.html +20 -0
  65. data/doc/classes/OAuthCampingPlugin/Helpers.src/M000033.html +20 -0
  66. data/doc/classes/OAuthCampingPlugin/Models.html +219 -0
  67. data/doc/classes/OAuthCampingPlugin/Models.src/M000035.html +55 -0
  68. data/doc/classes/OAuthCampingPlugin/Models.src/M000036.html +31 -0
  69. data/doc/classes/OAuthCampingPlugin/Models.src/M000037.html +56 -0
  70. data/doc/classes/OAuthCampingPlugin/Models.src/M000038.html +22 -0
  71. data/doc/classes/OAuthCampingPlugin/OAuth.html +407 -0
  72. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000004.html +18 -0
  73. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000005.html +18 -0
  74. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000006.html +20 -0
  75. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000007.html +20 -0
  76. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000008.html +20 -0
  77. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000009.html +24 -0
  78. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000010.html +20 -0
  79. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000011.html +18 -0
  80. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000012.html +19 -0
  81. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000013.html +26 -0
  82. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000014.html +26 -0
  83. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000015.html +33 -0
  84. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000016.html +18 -0
  85. data/doc/classes/OAuthCampingPlugin/OAuth.src/M000017.html +18 -0
  86. data/doc/classes/OAuthCampingPlugin/Views.html +257 -0
  87. data/doc/classes/OAuthCampingPlugin/Views.src/M000018.html +18 -0
  88. data/doc/classes/OAuthCampingPlugin/Views.src/M000019.html +18 -0
  89. data/doc/classes/OAuthCampingPlugin/Views.src/M000020.html +18 -0
  90. data/doc/classes/OAuthCampingPlugin/Views.src/M000021.html +18 -0
  91. data/doc/classes/OAuthCampingPlugin/Views.src/M000022.html +18 -0
  92. data/doc/classes/OAuthCampingPlugin/Views.src/M000023.html +41 -0
  93. data/doc/created.rid +1 -0
  94. data/doc/files/examples/camping-oauth-consumer/camping-oauth-consumer_rb.html +124 -0
  95. data/doc/files/examples/camping-oauth-provider/camping-oauth-provider_rb.html +101 -0
  96. data/doc/files/lib/camping-oauth_rb.html +576 -0
  97. data/doc/fr_class_index.html +56 -0
  98. data/doc/fr_file_index.html +29 -0
  99. data/doc/fr_method_index.html +86 -0
  100. data/doc/index.html +24 -0
  101. data/lib/camping-oauth.rb +1078 -0
  102. metadata +172 -0
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>common_oauth_views (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 937</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">common_oauth_views</span>
15
+ <span class="ruby-value str">&quot;\ndef authorize_failure\nh1 \&quot;You have denied access to this token\&quot;\nend\n\ndef authorize_failure_token_not_found\nh1 \&quot;Token not found\&quot;\nend\n\ndef authorize_failure_invalidated\nh1 \&quot;Token could not be authorized since it has become invalid\&quot;\nend\n\ndef authorize_success\nh1 \&quot;You have successfully authorized access to this token\&quot;\np @info\nend\n\ndef revoke_success\nh1 \&quot;You have successfully revoked access to this token\&quot;\np @info\nend\n&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>register_view (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 966</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">register_view</span>
15
+ <span class="ruby-value str">&quot;\ndef new_application_registration\nh2 \&quot;New OAuth Consumer\&quot;\nh3 \&quot;Application Registration\&quot;\ndiv.info @info if @info\nform.new_app_reg! :action =&gt; R(OAuthRegisterApplication), :method =&gt; 'post' do\nlabel 'Name (*)', :for =&gt; 'name'; br\ninput.app_name! :name =&gt; 'name', :type =&gt; 'text'; br\n\nlabel 'Url (*)', :for =&gt; 'url'; br\ninput.url :name =&gt; 'url', :type =&gt; 'text'; br\n\nlabel 'Callback Url (*)', :for =&gt; 'callback_url'; br\ninput.url :name =&gt; 'callback_url', :type =&gt; 'text'; br;\n\nlabel 'Support Url', :for =&gt; 'support_url'; br\ninput.url :name =&gt; 'support_url', :type =&gt; 'text'; br;br;\n\ninput :type =&gt; 'submit', :name =&gt; 'signup', :value =&gt; 'Register'\nend\nend\n\n&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>registration_view (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 995</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">registration_view</span>
15
+ <span class="ruby-value str">&quot;\ndef application_registration\nh2 \&quot;Application Registration\&quot;\ndiv @info if @info\n\ntable.application_registration do\ntr { td \&quot;Name\&quot;; td @application.name}\ntr { td \&quot;Url\&quot;; td @application.url}\ntr { td \&quot;Support Url\&quot;; td @application.support_url}\ntr { td \&quot;Callback Url\&quot;; td @application.callback_url}\ntr { td \&quot;Key\&quot;; td @application.key}\ntr { td \&quot;Secret\&quot;; td @application.secret}\nend\nend\n\n&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>authorize_view (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 1017</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authorize_view</span>
15
+ <span class="ruby-value str">&quot;\ndef authorize\ndiv @info if @info\nform :action =&gt; R(OAuthAuthorizeToken), :method =&gt; 'post' do\ninput :name =&gt; 'oauth_token', :type=&gt;'hidden', :value=&gt;@oauth_token;\ninput :name =&gt; 'authorize', :type=&gt;'checkbox';\nlabel 'Authorize token ' + @oauth_token, :for =&gt; 'authorize'; br\n\ninput :type =&gt; 'submit', :name =&gt; 'authorize_btn', :value =&gt; 'Authorize'\na \&quot;Cancel\&quot;, :href=&gt;\&quot;/applications\&quot;\nend\nend\n\n&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>revoke_view (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 1037</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">revoke_view</span>
15
+ <span class="ruby-value str">&quot;\ndef revoke\ndiv @info if @info\nform :action =&gt; R(OAuthRevokeToken), :method =&gt; 'post' do\ninput :name =&gt; 'oauth_token', :type=&gt;'hidden', :value=&gt;@token.token;\ninput :name =&gt; 'revoke', :type=&gt;'checkbox';\nlabel 'Revoke token ' + @token.token, :for =&gt; 'revoke'; br\n\ninput :type =&gt; 'submit', :name =&gt; 'revoke_btn', :value =&gt; 'Revoke'\na \&quot;Cancel\&quot;, :href=&gt;\&quot;/applications\&quot;\nend\nend\n\n&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>include_oauth_views (OAuthCampingPlugin::Views)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-oauth.rb, line 1058</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include_oauth_views</span>
15
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-constant">OAuthCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>.<span class="ruby-identifier">common_oauth_views</span>
16
+
17
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-keyword kw">do</span>
18
+ <span class="ruby-identifier">app_module_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">first</span>
19
+ <span class="ruby-identifier">mab_class_name</span> = <span class="ruby-node">&quot;#{app_module_name}::Mab&quot;</span>
20
+ <span class="ruby-identifier">mab_class</span> = <span class="ruby-identifier">mab_class_name</span>.<span class="ruby-identifier">constantize</span>
21
+
22
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mab_class</span>.<span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'register'</span>
23
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-constant">OAuthCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>.<span class="ruby-identifier">register_view</span>
24
+ <span class="ruby-keyword kw">end</span>
25
+
26
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mab_class</span>.<span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'application_registration'</span>
27
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-constant">OAuthCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>.<span class="ruby-identifier">registration_view</span>
28
+ <span class="ruby-keyword kw">end</span>
29
+
30
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mab_class</span>.<span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'authorize'</span>
31
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-constant">OAuthCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>.<span class="ruby-identifier">authorize_view</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+
34
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mab_class</span>.<span class="ruby-identifier">public_instance_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'revoke'</span>
35
+ <span class="ruby-identifier">module_eval</span> <span class="ruby-constant">OAuthCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>.<span class="ruby-identifier">revoke_view</span>
36
+ <span class="ruby-keyword kw">end</span>
37
+ <span class="ruby-keyword kw">end</span>
38
+
39
+ <span class="ruby-keyword kw">end</span></pre>
40
+ </body>
41
+ </html>
data/doc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Mon, 07 Jun 2010 05:09:03 -0600
@@ -0,0 +1,124 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: camping-oauth-consumer.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>camping-oauth-consumer.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>examples/camping-oauth-consumer/camping-oauth-consumer.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jun 02 20:18:43 -0600 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+ <div id="constants-list">
85
+ <h3 class="section-bar">Constants</h3>
86
+
87
+ <div class="name-list">
88
+ <table summary="Constants">
89
+ <tr class="top-aligned-row context-row">
90
+ <td class="context-item-name">CampingOAuthProvider_URL</td>
91
+ <td>=</td>
92
+ <td class="context-item-value">&quot;http://localhost:3301/&quot;</td>
93
+ </tr>
94
+ <tr class="top-aligned-row context-row">
95
+ <td class="context-item-name">CampingOAuthProvider_KEY</td>
96
+ <td>=</td>
97
+ <td class="context-item-value">&quot;SQnIXDQyhFB5q3wfZyMY&quot;</td>
98
+ </tr>
99
+ <tr class="top-aligned-row context-row">
100
+ <td class="context-item-name">CampingOAuthProvider_SECRET</td>
101
+ <td>=</td>
102
+ <td class="context-item-value">&quot;PmW02FNs7rXG97sAVXMWhFoJVZ98cnj21vv6p1ad&quot;</td>
103
+ </tr>
104
+ </table>
105
+ </div>
106
+ </div>
107
+
108
+
109
+
110
+
111
+
112
+
113
+ <!-- if method_list -->
114
+
115
+
116
+ </div>
117
+
118
+
119
+ <div id="validator-badges">
120
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
121
+ </div>
122
+
123
+ </body>
124
+ </html>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: camping-oauth-provider.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>camping-oauth-provider.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>examples/camping-oauth-provider/camping-oauth-provider.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jun 02 20:14:23 -0600 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -0,0 +1,576 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: camping-oauth.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>camping-oauth.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/camping-oauth.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Mon Jun 07 05:05:09 -0600 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <table>
73
+ <tr><td valign="top">Author:</td><td>Philippe F. Monnet (<a
74
+ href="mailto:pfmonnet@gmail.com">pfmonnet@gmail.com</a>)
75
+
76
+ </td></tr>
77
+ <tr><td valign="top">Copyright:</td><td>Copyright (c) 2010 Philippe F. Monnet - <a
78
+ href="../../classes/OAuth.html">OAuth</a> Camping plugin
79
+
80
+ </td></tr>
81
+ <tr><td valign="top">Copyright:</td><td>Copyright (c) 2009 Pelle Braendgaard - A subset of the Rails <a
82
+ href="../../classes/OAuth.html">OAuth</a> plugin reused in <a
83
+ href="../../classes/OAuth.html">OAuth</a> Camping
84
+
85
+ </td></tr>
86
+ <tr><td valign="top">License:</td><td>Distributes under the same terms as Ruby
87
+
88
+ </td></tr>
89
+ <tr><td valign="top">Version:</td><td>0.0.1
90
+
91
+ </td></tr>
92
+ </table>
93
+ <h1>Installing Camping-<a href="../../classes/OAuth.html">OAuth</a></h1>
94
+ <p>
95
+ A lightweight <a href="../../classes/OAuth.html">OAuth</a> plugin for Ruby
96
+ Camping. To install the library and its prerequisisites, type the following
97
+ commands:
98
+ </p>
99
+ <pre>
100
+ $ gem install filtering_camping
101
+ $ gem install oauth
102
+ $ gem install oauth-plugin
103
+ $ gem install camping-oauth
104
+ </pre>
105
+ <h1>Adding <a href="../../classes/OAuth.html">OAuth</a> Provider Support To Your App</h1>
106
+ <h3>Add new gem and require statements</h3>
107
+ <p>
108
+ Add the following statements towards the top of your source file (before
109
+ the Camping.goes statement):
110
+ </p>
111
+ <pre>
112
+ gem 'camping' , '&gt;= 2.0'
113
+ gem 'filtering_camping'
114
+ gem 'oauth'
115
+ gem 'oauth-plugin'
116
+
117
+ %w(rubygems active_record camping camping/session markaby json redcloth erb
118
+ oauth
119
+ oauth/server
120
+ oauth/request_proxy
121
+ oauth/request_proxy/rack_request
122
+ filtering_camping
123
+ camping-oauth
124
+ ).each { |lib| require lib }
125
+ </pre>
126
+ <h3>Customizing the main module</h3>
127
+ <p>
128
+ First we&#8216;ll make sure to include the Camping::Session and
129
+ CampingFilters modules, and to extend the app module with <a
130
+ href="../../classes/OAuthCampingPlugin.html">OAuthCampingPlugin</a>, like
131
+ so:
132
+ </p>
133
+ <pre>
134
+ module CampingOAuthProvider
135
+ include Camping::Session
136
+ include CampingFilters
137
+ extend OAuthCampingPlugin
138
+ include OAuthCampingPlugin::Filters
139
+
140
+ # ...
141
+ end
142
+ </pre>
143
+ <p>
144
+ This gives us the ability to leverage a logger for the camping-oauth
145
+ plugin.
146
+ </p>
147
+ <p>
148
+ <a
149
+ href="../../classes/OAuthCampingPlugin.html#M000001">OAuthCampingPlugin.logger</a>
150
+ = Logger.new(File.dirname(<em>FILE</em>) + &#8217;/yourmodule.log&#8217;);
151
+ <a
152
+ href="../../classes/OAuthCampingPlugin.html#M000001">OAuthCampingPlugin.logger</a>.level
153
+ = Logger::DEBUG
154
+ </p>
155
+ <p>
156
+ Now let&#8216;s customize the create method by adding a call to <a
157
+ href="../../classes/OAuthCampingPlugin.html#M000003">OAuthCampingPlugin.create</a>,
158
+ so we can give the plugin to run any needed initialization.
159
+ </p>
160
+ <pre>
161
+ def CampingOAuthProvider.create
162
+ OAuthCampingPlugin.create
163
+ end
164
+ </pre>
165
+ <p>
166
+ Ok, at this point we have a minimally configured application module. Our
167
+ next step is to move on to the Models module.
168
+ </p>
169
+ <h3>Plugging in the <a href="../../classes/OAuth.html">OAuth</a> models</h3>
170
+ <p>
171
+ First, we&#8216;ll include the include <a
172
+ href="../../classes/OAuthCampingPlugin/Models.html">OAuthCampingPlugin::Models</a>
173
+ module so we can get all the <a
174
+ href="../../classes/OAuth.html">OAuth</a>-specific models. Then we&#8216;ll
175
+ define a User model. The User will need to keep track of the applications
176
+ it provided access to. It will also manage the tokens associated with these
177
+ applications. Our model will look like this:
178
+ </p>
179
+ <pre>
180
+ class User &lt; Base;
181
+ has_many :client_applications
182
+ has_many :tokens,
183
+ :class_name=&gt;&quot;OauthToken&quot;,
184
+ :order=&gt;&quot;authorized_at desc&quot;,
185
+ :include=&gt;[:client_application]
186
+
187
+ end
188
+ </pre>
189
+ <p>
190
+ Now we need a CreateUserSchema migration class to define our database
191
+ tables for User, and <a href="../../classes/OAuth.html">OAuth</a> models.
192
+ In the up and down methods we will plugin a call to the corresponding
193
+ method from the <a
194
+ href="../../classes/OAuthCampingPlugin/Models.html">OAuthCampingPlugin::Models</a>
195
+ module to create the tables for ClientApplication, OAuthToken, and
196
+ OauthNonce.
197
+ </p>
198
+ <pre>
199
+ class CreateUserSchema &lt; V 1.0
200
+ def self.up
201
+ create_table :CampingOAuthProvider_users, :force =&gt; true do |t|
202
+ t.integer :id, :null =&gt; false
203
+ t.string :username
204
+ t.string :password
205
+ end
206
+
207
+ User.create :username =&gt; 'admin', :password =&gt; 'camping'
208
+
209
+ OAuthCampingPlugin::Models.up
210
+ end
211
+
212
+ def self.down
213
+ OAuthCampingPlugin::Models.down
214
+ drop_table :CampingOAuthProvider_users
215
+ end
216
+ end
217
+ </pre>
218
+ <p>
219
+ At this point we can go back to the main module and add the code to
220
+ configure the ActiveRecord connection and invoke our new schema migration
221
+ if the User table does not exist yet. This code will be added to the create
222
+ method:
223
+ </p>
224
+ <pre>
225
+ module CampingOAuthProvider
226
+ # ...
227
+
228
+ def CampingOAuthProvider.create
229
+ dbconfig = YAML.load(File.read('config/database.yml'))
230
+ Camping::Models::Base.establish_connection dbconfig['development']
231
+
232
+ OAuthCampingPlugin.create
233
+
234
+ CampingOAuthProvider::Models.create_schema :assume =&gt; (CampingOAuthProvider::Models::User.table_exists? ? 1.1 : 0.0)
235
+ end
236
+ end
237
+ </pre>
238
+ <p>
239
+ You probably noticed that the database configuration is loaded from a
240
+ database.yml file. So let&#8216;s create a subfolder named config and a
241
+ file named database.yml, then let&#8216;s configure the yaml file as
242
+ follows:
243
+ </p>
244
+ <pre>
245
+ development:
246
+ adapter: sqlite3
247
+ database: campingoauthprovider.db
248
+ </pre>
249
+ <p>
250
+ Now if we restart the application, our migration should be executed.
251
+ </p>
252
+ <h3>Creating a common helpers module</h3>
253
+ <p>
254
+ The Helpers module is used in Camping to provide common utilities to both
255
+ the Controllers and Views modules. Enhancing our Helpers module is very
256
+ easy, we need to add both and extend and an include of the <a
257
+ href="../../classes/OAuthCampingPlugin/Helpers.html">OAuthCampingPlugin::Helpers</a>
258
+ module so we can enhance both instance and class sides:
259
+ </p>
260
+ <pre>
261
+ module CampingOAuthProvider::Helpers
262
+ extend OAuthCampingPlugin::Helpers
263
+ include OAuthCampingPlugin::Helpers
264
+ end
265
+ </pre>
266
+ <h3>E.Plugging in the <a href="../../classes/OAuth.html">OAuth</a> controllers</h3>
267
+ <p>
268
+ We will need to extend our app Controllers module with the <a
269
+ href="../../classes/OAuthCampingPlugin/Controllers.html">OAuthCampingPlugin::Controllers</a>
270
+ module using the extend statement. Then just before the end of the
271
+ Controllers module, we&#8216;ll add a call to the include_oauth_controllers
272
+ method. This is how camping-oauth will inject and plugin the common <a
273
+ href="../../classes/OAuth.html">OAuth</a> controllers and helpers. It is
274
+ important that this call always remaining the last statement of the module,
275
+ even when you add new controller classes. So the module should look like
276
+ so:
277
+ </p>
278
+ <pre>
279
+ module CampingOAuthProvider::Controllers
280
+ extend OAuthCampingPlugin::Controllers
281
+
282
+ # ...
283
+
284
+ include_oauth_controllers
285
+ end #Controllers
286
+ </pre>
287
+ <p>
288
+ Before we continue fleshing out the logic of our controllers, let&#8216;s
289
+ finish hooking up the Views module.
290
+ </p>
291
+ <h3>Plugging in the <a href="../../classes/OAuth.html">OAuth</a> common views</h3>
292
+ <p>
293
+ We will need to extend our app Views module with the <a
294
+ href="../../classes/OAuthCampingPlugin/Views.html">OAuthCampingPlugin::Views</a>
295
+ module using the extend statement. Then just before the end of the Views
296
+ module, we&#8216;ll add a call to the include_oauth_views method. This is
297
+ how camping-oauth will inject and plugin the common <a
298
+ href="../../classes/OAuth.html">OAuth</a> views. It is important that this
299
+ call always remaining the last statement of the module, even when you add
300
+ new view methods. So the module should look like so:
301
+ </p>
302
+ <pre>
303
+ module CampingOAuthProvider::Views
304
+ extend OAuthCampingPlugin::Views
305
+
306
+ # ...
307
+
308
+ include_oauth_views
309
+ end
310
+ </pre>
311
+ <h3>Adding basic login and registration capabilities</h3>
312
+ <p>
313
+ Let&#8216;s add a Login controller class to our Controllers module:
314
+ </p>
315
+ <pre>
316
+ class Login &lt; R '/login'
317
+ def get
318
+ render :login
319
+ end
320
+
321
+ def post
322
+ @user = User.find_by_username_and_password(input.username, input.password)
323
+
324
+ if @user
325
+ @state.user_id = @user.id
326
+
327
+ if @state.return_to.nil?
328
+ redirect R(Index)
329
+ else
330
+ return_to = @state.return_to
331
+ @state.return_to = nil
332
+ redirect(return_to)
333
+ end
334
+ else
335
+ @info = 'Wrong username or password.'
336
+ end
337
+ render :login
338
+ end
339
+ end
340
+ </pre>
341
+ <p>
342
+ And now add the corresponding login view in the Views module&quot;
343
+ </p>
344
+ <pre>
345
+ def login
346
+ div @info if @info
347
+ form :action =&gt; R(Login), :method =&gt; 'post' do
348
+ label 'Username', :for =&gt; 'username'; br
349
+ input :name =&gt; 'username', :type =&gt; 'text'; br
350
+
351
+ label 'Password', :for =&gt; 'password'; br
352
+ input :name =&gt; 'password', :type =&gt; 'text'; br
353
+
354
+ input :type =&gt; 'submit', :name =&gt; 'login', :value =&gt; 'Login'
355
+ end
356
+ end
357
+ </pre>
358
+ <p>
359
+ Let&#8216;s verify we can login by accessing the following url:
360
+ </p>
361
+ <pre>
362
+ http://localhost:3301/login
363
+ </pre>
364
+ <p>
365
+ Now that login support is in place you can test out one of the <a
366
+ href="../../classes/OAuth.html">OAuth</a> controllers by navigating to the
367
+ following url:
368
+ </p>
369
+ <pre>
370
+ http://localhost:3301/oauth/register
371
+ </pre>
372
+ <p>
373
+ Since the camping-oauth plugin installed a :before filter on the
374
+ OAuthRegisterApplication controller requiring user login, you should be
375
+ redirected first to the login page. Since we created a default account when
376
+ running the migration, login as admin with camping as the password. Once
377
+ logged in you should be redirected back to the <a
378
+ href="../../classes/OAuth.html">OAuth</a> Application Registration page.
379
+ </p>
380
+ <p>
381
+ As a side note, you can style all common <a
382
+ href="../../classes/OAuth.html">OAuth</a> views later using CSS.
383
+ We&#8216;ll let you add the SignUp controller and its signup view on your
384
+ own.
385
+ </p>
386
+ <h3>Adding our custom API, protected by <a href="../../classes/OAuth.html">OAuth</a></h3>
387
+ <p>
388
+ Since the premise of this post was to make it easy for web apps to consume
389
+ an <a href="../../classes/OAuth.html">OAuth</a>-protected service,
390
+ let&#8216;s create a very simple controller (no view needed) to expose some
391
+ data as JSON.
392
+ </p>
393
+ <pre>
394
+ class APITimeNow &lt; R '/api/timenow'
395
+ def get
396
+ @result = {:now=&gt;Time.now.utc.to_s}
397
+ @result[:username] = @user.username if @user
398
+
399
+ @headers['Content-Type'] = &quot;application/json&quot;
400
+ log_debug @result.to_json
401
+ @result.to_json
402
+ end
403
+ end
404
+ </pre>
405
+ <p>
406
+ Now we can test it by navigating to the following url (after installing the
407
+ JSONview plugin for FireFox to make it easier to see the returned JSON
408
+ data):
409
+ </p>
410
+ <pre>
411
+ http://localhost:3301/api/timenow
412
+ </pre>
413
+ <p>
414
+ Note that at this point this controller is NOT YET protected by <a
415
+ href="../../classes/OAuth.html">OAuth</a>. For that we need to declare a
416
+ before filter for the APITimeNow controller requiring to be either logged
417
+ in or <a href="../../classes/OAuth.html">OAuth</a>-authenticated. So
418
+ let&#8216;s add this code snippet to our main module:
419
+ </p>
420
+ <pre>
421
+ module GatedCampingSite
422
+ # ...
423
+
424
+ before [:APITimeNow] do
425
+ login_or_oauth_required
426
+ end
427
+
428
+ # ...
429
+ end
430
+ </pre>
431
+ <p>
432
+ So now if we logged out (by deleting the session cookies since we have not
433
+ implemented logoff) and refreshed our browser we would be redirected to the
434
+ login page.
435
+ </p>
436
+ <h2>Testing And Troubleshooting</h2>
437
+ <p>
438
+ At this stage, we have a basic Camping <a
439
+ href="../../classes/OAuth.html">OAuth</a> provider, now let&#8216;s test
440
+ it! The first thing is to register a new <a
441
+ href="../../classes/OAuth.html">OAuth</a> consumer named
442
+ camping-oauth-consumer. We&#8216;ll assume that:
443
+ </p>
444
+ <pre>
445
+ 1. it is located at http://localhost:3000/ (fictitious for now)
446
+ 2. it exposes a url: http://localhost:3000/callback to accept an OAuth token once authorized
447
+ </pre>
448
+ <p>
449
+ Once you register you should see the a page with the registration results.
450
+ The key and secret will be used by our consumer as credentials when
451
+ accessing our <a href="../../classes/OAuth.html">OAuth</a> provider, so
452
+ copy/paste them into a notepad.
453
+ </p>
454
+ <p>
455
+ For our first test consumer will use IRB, so open up a session and
456
+ let&#8216;s define 3 variables for: url of our provider, key and secret
457
+ (use your own values) of our registered consumer:
458
+ </p>
459
+ <pre>
460
+ @site={:site=&gt;&quot;http://localhost:3301&quot;}
461
+ @mykey=&quot;SQnIXDQyhFB5q3wfZyMY&quot;
462
+ @mysecret=&quot;PmW02FNs7rXG97sAVXMWhFoJVZ98cnj21vv6p1ad&quot;
463
+ </pre>
464
+ <p>
465
+ Now let&#8216;s require oauth and let&#8216;s instantiate an <a
466
+ href="../../classes/OAuth.html">OAuth</a> consumer:
467
+ </p>
468
+ <pre>
469
+ require 'oauth'
470
+ @consumer = OAuth::Consumer.new(@mykey,@mysecret,@site)
471
+ </pre>
472
+ <p>
473
+ You should get an instance of a OAuth::Consumer back. Our next step is to
474
+ request an <a href="../../classes/OAuth.html">OAuth</a> RequestToken like
475
+ so:
476
+ </p>
477
+ <pre>
478
+ @request_token = @consumer.get_request_token
479
+ </pre>
480
+ <p>
481
+ You should get an OAuth::RequestToken back. Let&#8216;s see how and where
482
+ we should authorize this request token:
483
+ </p>
484
+ <pre>
485
+ http://localhost:3301/oauth/authorize?oauth_token=0Qd6g3SjWHQEM6sUTcd9
486
+ </pre>
487
+ <p>
488
+ We should be prompted by the <a href="../../classes/OAuth.html">OAuth</a>
489
+ Authorization controller of our provider. If you click on the checkbox and
490
+ the Authorize button, the provider will redirect you to the callback url we
491
+ defined during registration passing back the Oauth token id and and a
492
+ verifier code. Since we don&#8216;t have a consumer web app up and running,
493
+ we will get a navigation error. Here is what the target (redirection) url
494
+ looks like:
495
+ </p>
496
+ <pre>
497
+ http://localhost:3000/callback?oauth_token=0Qd6g3SjWHQEM6sUTcd9&amp;oauth_verifier=71Jt3GhiwvHlZYO9zA8c
498
+ </pre>
499
+ <p>
500
+ This verifier acts as a sort of session id we need to pass to get an <a
501
+ href="../../classes/OAuth.html">OAuth</a> Access Token. So from our IRB
502
+ session, let&#8216;s evaluate the following statement:
503
+ </p>
504
+ <pre>
505
+ @verifier = '71Jt3GhiwvHlZYO9zA8c'
506
+ @access_token = @request_token.get_access_token(:oauth_verifier=&gt;@verifier)
507
+ </pre>
508
+ <p>
509
+ You should get an instance of OAuth::AccessToken back. So now let&#8216;s
510
+ call our provider api:
511
+ </p>
512
+ <pre>
513
+ @response = @access_token.get('/api/timenow')
514
+ @info = @response.body
515
+ </pre>
516
+ <p>
517
+ You should get back a JSON object. So this concludes our whirlwind tour of
518
+ <a href="../../classes/OAuth.html">OAuth</a> from a provider and consumer
519
+ side.
520
+ </p>
521
+ <h3>Examples Source Code</h3>
522
+ <p>
523
+ Also if you look in the examples folder of the camping-oauth gem you will
524
+ find the full source for both a provider (the one we have been working on)
525
+ and a consumer app (to be run on port 3302).
526
+ </p>
527
+ <h1>More information</h1>
528
+ <p>
529
+ Check for updates :
530
+ </p>
531
+ <ul>
532
+ <li><a href="http://blog.monnet-usa.com">blog.monnet-usa.com</a>
533
+
534
+ </li>
535
+ </ul>
536
+
537
+ </div>
538
+
539
+ <div id="requires-list">
540
+ <h3 class="section-bar">Required files</h3>
541
+
542
+ <div class="name-list">
543
+ oauth&nbsp;&nbsp;
544
+ activerecord&nbsp;&nbsp;
545
+ </div>
546
+ </div>
547
+
548
+ </div>
549
+
550
+
551
+ </div>
552
+
553
+
554
+ <!-- if includes -->
555
+
556
+ <div id="section">
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+ <!-- if method_list -->
566
+
567
+
568
+ </div>
569
+
570
+
571
+ <div id="validator-badges">
572
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
573
+ </div>
574
+
575
+ </body>
576
+ </html>