gcalapi 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/Rakefile +19 -15
  2. data/VERSION +1 -1
  3. data/example/mixi2gcal.rb +88 -0
  4. data/html/classes/GoogleCalendar.html +149 -280
  5. data/html/classes/GoogleCalendar/AuthSubFailed.html +165 -0
  6. data/html/classes/GoogleCalendar/AuthSubUtil.html +397 -0
  7. data/html/classes/GoogleCalendar/AuthenticationFailed.html +110 -110
  8. data/html/classes/GoogleCalendar/Calendar.html +381 -203
  9. data/html/classes/GoogleCalendar/Event.html +800 -510
  10. data/html/classes/GoogleCalendar/EventDeleteFailed.html +110 -110
  11. data/html/classes/GoogleCalendar/EventGetFailed.html +111 -0
  12. data/html/classes/GoogleCalendar/EventInsertFailed.html +110 -110
  13. data/html/classes/GoogleCalendar/EventUpdateFailed.html +110 -110
  14. data/html/classes/GoogleCalendar/InvalidCalendarURL.html +110 -110
  15. data/html/classes/GoogleCalendar/Service.html +305 -594
  16. data/html/classes/GoogleCalendar/ServiceAuthSub.html +181 -0
  17. data/html/classes/GoogleCalendar/ServiceBase.html +694 -0
  18. data/html/created.rid +1 -1
  19. data/html/files/README.html +116 -116
  20. data/html/files/lib/googlecalendar/auth_sub_util_rb.html +111 -0
  21. data/html/files/lib/googlecalendar/calendar_rb.html +109 -109
  22. data/html/files/lib/googlecalendar/event_rb.html +109 -109
  23. data/html/files/lib/googlecalendar/service_auth_sub_rb.html +108 -0
  24. data/html/files/lib/googlecalendar/service_base_rb.html +114 -0
  25. data/html/files/lib/googlecalendar/service_rb.html +107 -113
  26. data/html/fr_class_index.html +39 -34
  27. data/html/fr_file_index.html +32 -29
  28. data/html/fr_method_index.html +75 -52
  29. data/html/index.html +23 -23
  30. data/html/rdoc-style.css +207 -207
  31. data/lib/googlecalendar/auth_sub_util.rb +143 -0
  32. data/lib/googlecalendar/calendar.rb +48 -36
  33. data/lib/googlecalendar/event.rb +16 -11
  34. data/lib/googlecalendar/service.rb +30 -180
  35. data/lib/googlecalendar/service_auth_sub.rb +18 -0
  36. data/lib/googlecalendar/service_base.rb +197 -0
  37. data/test/00_service_test.rb +2 -1
  38. data/test/01_calendar_test.rb +1 -1
  39. data/test/02_event_test.rb +28 -1
  40. data/test/03_authsub_test.rb +119 -0
  41. data/test/base_unit.rb +3 -0
  42. metadata +105 -62
@@ -0,0 +1,165 @@
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>Class: GoogleCalendar::AuthSubFailed</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="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">GoogleCalendar::AuthSubFailed</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/googlecalendar/auth_sub_util_rb.html">
59
+ lib/googlecalendar/auth_sub_util.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ StandardError
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ Exception about AuthSub
84
+ </p>
85
+
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+ <div id="method-list">
92
+ <h3 class="section-bar">Methods</h3>
93
+
94
+ <div class="name-list">
95
+ <a href="#M000003">new</a>&nbsp;&nbsp;
96
+ </div>
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+ <!-- if includes -->
103
+
104
+ <div id="section">
105
+
106
+
107
+
108
+
109
+
110
+ <div id="attribute-list">
111
+ <h3 class="section-bar">Attributes</h3>
112
+
113
+ <div class="name-list">
114
+ <table>
115
+ <tr class="top-aligned-row context-row">
116
+ <td class="context-item-name">http_response</td>
117
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
118
+ <td class="context-item-desc"></td>
119
+ </tr>
120
+ </table>
121
+ </div>
122
+ </div>
123
+
124
+
125
+
126
+ <!-- if method_list -->
127
+ <div id="methods">
128
+ <h3 class="section-bar">Public Class methods</h3>
129
+
130
+ <div id="method-M000003" class="method-detail">
131
+ <a name="M000003"></a>
132
+
133
+ <div class="method-heading">
134
+ <a href="#M000003" class="method-signature">
135
+ <span class="method-name">new</span><span class="method-args">(res)</span>
136
+ </a>
137
+ </div>
138
+
139
+ <div class="method-description">
140
+ <p><a class="source-toggle" href="#"
141
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
142
+ <div class="method-source-code" id="M000003-source">
143
+ <pre>
144
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 13</span>
145
+ 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">res</span>)
146
+ 14: <span class="ruby-identifier">http_response</span> = <span class="ruby-identifier">res</span>
147
+ 15: <span class="ruby-keyword kw">end</span>
148
+ </pre>
149
+ </div>
150
+ </div>
151
+ </div>
152
+
153
+
154
+ </div>
155
+
156
+
157
+ </div>
158
+
159
+
160
+ <div id="validator-badges">
161
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
162
+ </div>
163
+
164
+ </body>
165
+ </html>
@@ -0,0 +1,397 @@
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>Class: GoogleCalendar::AuthSubUtil</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="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">GoogleCalendar::AuthSubUtil</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/googlecalendar/auth_sub_util_rb.html">
59
+ lib/googlecalendar/auth_sub_util.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <h1>Summary</h1>
83
+ <p>
84
+ Helper class for AuthSub authentication. For detail, see <a
85
+ href="http://code.google.com/apis/accounts/AuthForWebApps.html">code.google.com/apis/accounts/AuthForWebApps.html</a>
86
+ Currently, this class is available for only unregistered website.
87
+ </p>
88
+ <h1>How to use this class</h1>
89
+ <h2>Show AuthSubRequest link to a user.</h2>
90
+ <pre>
91
+ First, you need to show your user an anchor to the AuthSubRequest. The user can get authentication token
92
+ in the page. And the user will redirect back to your Website with authentication token.
93
+
94
+ request_url = AuthSubUtil.build_request_url(next_url, AuthSubUtil::CALENDAR_SCOPE, use_secure, use_session)
95
+ </pre>
96
+ <h2>Get token from redirected URL.</h2>
97
+ <pre>
98
+ The redirected URL string contains one time session token. You can get the token using get_one_time_token method.
99
+
100
+ token = AuthSubUtil.get_one_time_token(urlstr)
101
+ </pre>
102
+ <h2>Get session token.</h2>
103
+ <pre>
104
+ You will get an one time token above process. Then you can get longtime living sessin token.
105
+
106
+ session = AuthSubUtil.exchange_session_token(one_time_token)
107
+ </pre>
108
+ <h2>make a <a href="ServiceAuthSub.html">ServiceAuthSub</a> instance instead of <a href="Service.html">Service</a>.</h2>
109
+ <pre>
110
+ srv = GoogleCalendar::ServiceAuthSub.new(session_token)
111
+ </pre>
112
+ <h2>Revoke session token.</h2>
113
+ <pre>
114
+ Google limits the number of session token per user. So you should revoke the session token after using.
115
+
116
+ AuthSubUtil.revoke_session_token(session_token)
117
+ </pre>
118
+
119
+ </div>
120
+
121
+
122
+ </div>
123
+
124
+ <div id="method-list">
125
+ <h3 class="section-bar">Methods</h3>
126
+
127
+ <div class="name-list">
128
+ <a href="#M000004">build_request_url</a>&nbsp;&nbsp;
129
+ <a href="#M000009">do_get_with_ssl</a>&nbsp;&nbsp;
130
+ <a href="#M000006">exchange_session_token</a>&nbsp;&nbsp;
131
+ <a href="#M000005">get_one_time_token</a>&nbsp;&nbsp;
132
+ <a href="#M000007">revoke_session_token</a>&nbsp;&nbsp;
133
+ <a href="#M000008">token_info</a>&nbsp;&nbsp;
134
+ </div>
135
+ </div>
136
+
137
+ </div>
138
+
139
+
140
+ <!-- if includes -->
141
+
142
+ <div id="section">
143
+
144
+
145
+ <div id="constants-list">
146
+ <h3 class="section-bar">Constants</h3>
147
+
148
+ <div class="name-list">
149
+ <table summary="Constants">
150
+ <tr class="top-aligned-row context-row">
151
+ <td class="context-item-name">REQUEST_URL</td>
152
+ <td>=</td>
153
+ <td class="context-item-value">&quot;https://www.google.com/accounts/AuthSubRequest&quot;</td>
154
+ </tr>
155
+ <tr class="top-aligned-row context-row">
156
+ <td class="context-item-name">SESSION_URL</td>
157
+ <td>=</td>
158
+ <td class="context-item-value">&quot;https://www.google.com/accounts/AuthSubSessionToken&quot;</td>
159
+ </tr>
160
+ <tr class="top-aligned-row context-row">
161
+ <td class="context-item-name">REVOKE_URL</td>
162
+ <td>=</td>
163
+ <td class="context-item-value">&quot;https://www.google.com/accounts/AuthSubRevokeToken&quot;</td>
164
+ </tr>
165
+ <tr class="top-aligned-row context-row">
166
+ <td class="context-item-name">INFO_URL</td>
167
+ <td>=</td>
168
+ <td class="context-item-value">&quot;https://www.google.com/accounts/AuthSubTokenInfo&quot;</td>
169
+ </tr>
170
+ <tr class="top-aligned-row context-row">
171
+ <td class="context-item-name">CALENDAR_SCOPE</td>
172
+ <td>=</td>
173
+ <td class="context-item-value">&quot;http://www.google.com/calendar/feeds/&quot;</td>
174
+ </tr>
175
+ </table>
176
+ </div>
177
+ </div>
178
+
179
+
180
+
181
+
182
+
183
+
184
+ <!-- if method_list -->
185
+ <div id="methods">
186
+ <h3 class="section-bar">Public Class methods</h3>
187
+
188
+ <div id="method-M000004" class="method-detail">
189
+ <a name="M000004"></a>
190
+
191
+ <div class="method-heading">
192
+ <a href="#M000004" class="method-signature">
193
+ <span class="method-name">build_request_url</span><span class="method-args">(next_url, scope, use_secure, use_session)</span>
194
+ </a>
195
+ </div>
196
+
197
+ <div class="method-description">
198
+ <p>
199
+ Build url for AuthSubRequest. <a
200
+ href="http://code.google.com/apis/accounts/AuthForWebApps.html#AuthSubRequest">code.google.com/apis/accounts/AuthForWebApps.html#AuthSubRequest</a>
201
+ Currently, secure token is not implemented.
202
+ </p>
203
+ <p><a class="source-toggle" href="#"
204
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
205
+ <div class="method-source-code" id="M000004-source">
206
+ <pre>
207
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 67</span>
208
+ 67: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">build_request_url</span>(<span class="ruby-identifier">next_url</span>, <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">use_secure</span>, <span class="ruby-identifier">use_session</span>)
209
+ 68: <span class="ruby-identifier">hq</span> = [[<span class="ruby-value str">&quot;next&quot;</span>, <span class="ruby-identifier">next_url</span>],
210
+ 69: [<span class="ruby-value str">&quot;scope&quot;</span>, <span class="ruby-constant">CALENDAR_SCOPE</span>],
211
+ 70: [<span class="ruby-value str">&quot;secure&quot;</span>, <span class="ruby-identifier">use_secure</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;1&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;0&quot;</span>],
212
+ 71: [<span class="ruby-value str">&quot;session&quot;</span>, <span class="ruby-identifier">use_session</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;1&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;0&quot;</span>]]
213
+ 72: <span class="ruby-identifier">query</span> = <span class="ruby-identifier">hq</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">elem</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{elem[0]}=#{CGI.escape(elem[1])}&quot;</span> <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;&amp;&quot;</span>)
214
+ 73: <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;#{REQUEST_URL}?#{query}&quot;</span>
215
+ 74: <span class="ruby-keyword kw">end</span>
216
+ </pre>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <div id="method-M000006" class="method-detail">
222
+ <a name="M000006"></a>
223
+
224
+ <div class="method-heading">
225
+ <a href="#M000006" class="method-signature">
226
+ <span class="method-name">exchange_session_token</span><span class="method-args">(one_time_token)</span>
227
+ </a>
228
+ </div>
229
+
230
+ <div class="method-description">
231
+ <p>
232
+ Get session token. The authentication token you get by calling
233
+ AuthSubRequest is available only once. To get long-lived token, use this.
234
+ For detail, see <a
235
+ href="http://code.google.com/apis/accounts/AuthForWebApps.html#AuthSubSessionToken">code.google.com/apis/accounts/AuthForWebApps.html#AuthSubSessionToken</a>
236
+ </p>
237
+ <p><a class="source-toggle" href="#"
238
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
239
+ <div class="method-source-code" id="M000006-source">
240
+ <pre>
241
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 95</span>
242
+ 95: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">exchange_session_token</span>(<span class="ruby-identifier">one_time_token</span>)
243
+ 96: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">do_get_with_ssl</span>(<span class="ruby-constant">SESSION_URL</span>, <span class="ruby-identifier">one_time_token</span>)
244
+ 97: <span class="ruby-identifier">throw</span> <span class="ruby-constant">AuthSubFailed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;200&quot;</span>
245
+ 98: <span class="ruby-identifier">session_token</span> = <span class="ruby-keyword kw">nil</span>
246
+ 99: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/Token=(.*)$/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>
247
+ 100: <span class="ruby-identifier">session_token</span> = <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">to_s</span>
248
+ 101: <span class="ruby-keyword kw">else</span>
249
+ 102: <span class="ruby-identifier">throw</span> <span class="ruby-constant">AuthSubFailed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>), <span class="ruby-value str">&quot;Token not found&quot;</span>
250
+ 103: <span class="ruby-keyword kw">end</span>
251
+ 104: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">session_token</span>
252
+ 105: <span class="ruby-keyword kw">end</span>
253
+ </pre>
254
+ </div>
255
+ </div>
256
+ </div>
257
+
258
+ <div id="method-M000005" class="method-detail">
259
+ <a name="M000005"></a>
260
+
261
+ <div class="method-heading">
262
+ <a href="#M000005" class="method-signature">
263
+ <span class="method-name">get_one_time_token</span><span class="method-args">(url_str)</span>
264
+ </a>
265
+ </div>
266
+
267
+ <div class="method-description">
268
+ <p>
269
+ Get authentication token from the redirected url. When the AuthSubRequest
270
+ is accepted, the edirected URL string (specified in next_url parameter of
271
+ build_reque4st_url method) contains authentication token. This method
272
+ retrieves the token from url string. This token is for a single use only.
273
+ To get long-lived token, use <a
274
+ href="AuthSubUtil.html#M000006">exchange_session_token</a> method.
275
+ </p>
276
+ <p><a class="source-toggle" href="#"
277
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
278
+ <div class="method-source-code" id="M000005-source">
279
+ <pre>
280
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 82</span>
281
+ 82: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_one_time_token</span>(<span class="ruby-identifier">url_str</span>)
282
+ 83: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url_str</span>)
283
+ 84: <span class="ruby-identifier">params</span> = <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>)
284
+ 85: <span class="ruby-identifier">throw</span> <span class="ruby-constant">AuthSubFailed</span>, <span class="ruby-value str">&quot;Token is not found&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">&quot;token&quot;</span>)
285
+ 86: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">params</span>[<span class="ruby-value str">&quot;token&quot;</span>][<span class="ruby-value">0</span>]
286
+ 87: <span class="ruby-keyword kw">end</span>
287
+ </pre>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <div id="method-M000007" class="method-detail">
293
+ <a name="M000007"></a>
294
+
295
+ <div class="method-heading">
296
+ <a href="#M000007" class="method-signature">
297
+ <span class="method-name">revoke_session_token</span><span class="method-args">(session_token)</span>
298
+ </a>
299
+ </div>
300
+
301
+ <div class="method-description">
302
+ <p>
303
+ You can get session token by calling <a
304
+ href="AuthSubUtil.html#M000006">exchange_session_token</a> method. Session
305
+ token will remain until you revoke. For detail, <a
306
+ href="http://code.google.com/apis/accounts/AuthForWebApps.html#AuthSubRevokeToken">code.google.com/apis/accounts/AuthForWebApps.html#AuthSubRevokeToken</a>
307
+ </p>
308
+ <p><a class="source-toggle" href="#"
309
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
310
+ <div class="method-source-code" id="M000007-source">
311
+ <pre>
312
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 112</span>
313
+ 112: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">revoke_session_token</span>(<span class="ruby-identifier">session_token</span>)
314
+ 113: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">do_get_with_ssl</span>(<span class="ruby-constant">REVOKE_URL</span>, <span class="ruby-identifier">session_token</span>)
315
+ 114: <span class="ruby-identifier">throw</span> <span class="ruby-constant">AuthSubFailed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;200&quot;</span>
316
+ 115: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
317
+ 116: <span class="ruby-keyword kw">end</span>
318
+ </pre>
319
+ </div>
320
+ </div>
321
+ </div>
322
+
323
+ <div id="method-M000008" class="method-detail">
324
+ <a name="M000008"></a>
325
+
326
+ <div class="method-heading">
327
+ <a href="#M000008" class="method-signature">
328
+ <span class="method-name">token_info</span><span class="method-args">(session_token)</span>
329
+ </a>
330
+ </div>
331
+
332
+ <div class="method-description">
333
+ <p><a class="source-toggle" href="#"
334
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
335
+ <div class="method-source-code" id="M000008-source">
336
+ <pre>
337
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 119</span>
338
+ 119: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">token_info</span>(<span class="ruby-identifier">session_token</span>)
339
+ 120: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">do_get_with_ssl</span>(<span class="ruby-constant">INFO_URL</span>, <span class="ruby-identifier">session_token</span>)
340
+ 121: <span class="ruby-identifier">throw</span> <span class="ruby-constant">AuthSubFailed</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>), <span class="ruby-identifier">res</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;200&quot;</span>
341
+ 122: <span class="ruby-identifier">ret</span> = {}
342
+ 123: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
343
+ 124: <span class="ruby-identifier">ret</span>[<span class="ruby-identifier">$1</span>] = <span class="ruby-identifier">$2</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^([^=]+)=(.+)$/</span>
344
+ 125: <span class="ruby-keyword kw">end</span>
345
+ 126: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret</span>
346
+ 127: <span class="ruby-keyword kw">end</span>
347
+ </pre>
348
+ </div>
349
+ </div>
350
+ </div>
351
+
352
+ <h3 class="section-bar">Private Class methods</h3>
353
+
354
+ <div id="method-M000009" class="method-detail">
355
+ <a name="M000009"></a>
356
+
357
+ <div class="method-heading">
358
+ <a href="#M000009" class="method-signature">
359
+ <span class="method-name">do_get_with_ssl</span><span class="method-args">(str_uri, token)</span>
360
+ </a>
361
+ </div>
362
+
363
+ <div class="method-description">
364
+ <p><a class="source-toggle" href="#"
365
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
366
+ <div class="method-source-code" id="M000009-source">
367
+ <pre>
368
+ <span class="ruby-comment cmt"># File lib/googlecalendar/auth_sub_util.rb, line 131</span>
369
+ 131: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">do_get_with_ssl</span>(<span class="ruby-identifier">str_uri</span>, <span class="ruby-identifier">token</span>)
370
+ 132: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">nil</span>
371
+ 133: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">str_uri</span>)
372
+ 134: <span class="ruby-identifier">https</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>)
373
+ 135: <span class="ruby-identifier">https</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
374
+ 136: <span class="ruby-identifier">https</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
375
+ 137: <span class="ruby-identifier">https</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
376
+ 138: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>, {<span class="ruby-value str">&quot;Authorization&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;AuthSub token=\&quot;#{token}\&quot;&quot;</span>})
377
+ 139: <span class="ruby-keyword kw">end</span>
378
+ 140: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
379
+ 141: <span class="ruby-keyword kw">end</span>
380
+ </pre>
381
+ </div>
382
+ </div>
383
+ </div>
384
+
385
+
386
+ </div>
387
+
388
+
389
+ </div>
390
+
391
+
392
+ <div id="validator-badges">
393
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
394
+ </div>
395
+
396
+ </body>
397
+ </html>