Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 1 | <?xml version="1.0" encoding="ascii"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "DTD/xhtml1-transitional.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | <head> |
| 6 | <title>oauth2client.tools</title> |
| 7 | <link rel="stylesheet" href="epydoc.css" type="text/css" /> |
| 8 | <script type="text/javascript" src="epydoc.js"></script> |
| 9 | </head> |
| 10 | |
| 11 | <body bgcolor="white" text="black" link="blue" vlink="#204080" |
| 12 | alink="#204080"> |
| 13 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 14 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 15 | bgcolor="#a0c0ff" cellspacing="0"> |
| 16 | <tr valign="middle"> |
| 17 | |
| 18 | <!-- Tree link --> |
| 19 | <th> <a |
| 20 | href="module-tree.html">Trees</a> </th> |
| 21 | |
| 22 | <!-- Index link --> |
| 23 | <th> <a |
| 24 | href="identifier-index.html">Indices</a> </th> |
| 25 | |
| 26 | <!-- Help link --> |
| 27 | <th> <a |
| 28 | href="help.html">Help</a> </th> |
| 29 | |
| 30 | <th class="navbar" width="100%"></th> |
| 31 | </tr> |
| 32 | </table> |
| 33 | <table width="100%" cellpadding="0" cellspacing="0"> |
| 34 | <tr valign="top"> |
| 35 | <td width="100%"> |
| 36 | <span class="breadcrumbs"> |
| 37 | <a href="oauth2client-module.html">Package oauth2client</a> :: |
| 38 | Module tools |
| 39 | </span> |
| 40 | </td> |
| 41 | <td> |
| 42 | <table cellpadding="0" cellspacing="0"> |
| 43 | <!-- hide/show private --> |
| 44 | <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" |
| 45 | onclick="toggle_private();">hide private</a>]</span></td></tr> |
| 46 | <tr><td align="right"><span class="options" |
| 47 | >[<a href="frames.html" target="_top">frames</a |
| 48 | >] | <a href="oauth2client.tools-module.html" |
| 49 | target="_top">no frames</a>]</span></td></tr> |
| 50 | </table> |
| 51 | </td> |
| 52 | </tr> |
| 53 | </table> |
| 54 | <!-- ==================== MODULE DESCRIPTION ==================== --> |
| 55 | <h1 class="epydoc">Module tools</h1><p class="nomargin-top"><span class="codelink"><a href="oauth2client.tools-pysrc.html">source code</a></span></p> |
| 56 | <pre class="literalblock"> |
| 57 | Command-line tools for authenticating via OAuth 2.0 |
| 58 | |
| 59 | Do the OAuth 2.0 Web Server dance for a command line application. Stores the |
| 60 | generated credentials in a common file that is used by other example apps in |
| 61 | the same directory. |
| 62 | |
| 63 | </pre> |
| 64 | |
| 65 | <hr /> |
| 66 | <div class="fields"> <p><strong>Author:</strong> |
| 67 | jcgregorio@google.com (Joe Gregorio) |
| 68 | </p> |
| 69 | </div><!-- ==================== CLASSES ==================== --> |
| 70 | <a name="section-Classes"></a> |
| 71 | <table class="summary" border="1" cellpadding="3" |
| 72 | cellspacing="0" width="100%" bgcolor="white"> |
| 73 | <tr bgcolor="#70b0f0" class="table-header"> |
| 74 | <td colspan="2" class="table-header"> |
| 75 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 76 | <tr valign="top"> |
| 77 | <td align="left"><span class="table-header">Classes</span></td> |
| 78 | <td align="right" valign="top" |
| 79 | ><span class="options">[<a href="#section-Classes" |
| 80 | class="privatelink" onclick="toggle_private();" |
| 81 | >hide private</a>]</span></td> |
| 82 | </tr> |
| 83 | </table> |
| 84 | </td> |
| 85 | </tr> |
| 86 | <tr class="private"> |
| 87 | <td width="15%" align="right" valign="top" class="summary"> |
| 88 | <span class="summary-type"> </span> |
| 89 | </td><td class="summary"> |
| 90 | <a href="oauth2client.tools.ClientRedirectServer-class.html" class="summary-name" onclick="show_private();">ClientRedirectServer</a><br /> |
| 91 | A server to handle OAuth 2.0 redirects back to localhost. |
| 92 | </td> |
| 93 | </tr> |
| 94 | <tr class="private"> |
| 95 | <td width="15%" align="right" valign="top" class="summary"> |
| 96 | <span class="summary-type"> </span> |
| 97 | </td><td class="summary"> |
| 98 | <a href="oauth2client.tools.ClientRedirectHandler-class.html" class="summary-name" onclick="show_private();">ClientRedirectHandler</a><br /> |
| 99 | A handler for OAuth 2.0 redirects back to localhost. |
| 100 | </td> |
| 101 | </tr> |
| 102 | </table> |
| 103 | <!-- ==================== FUNCTIONS ==================== --> |
| 104 | <a name="section-Functions"></a> |
| 105 | <table class="summary" border="1" cellpadding="3" |
| 106 | cellspacing="0" width="100%" bgcolor="white"> |
| 107 | <tr bgcolor="#70b0f0" class="table-header"> |
| 108 | <td colspan="2" class="table-header"> |
| 109 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 110 | <tr valign="top"> |
| 111 | <td align="left"><span class="table-header">Functions</span></td> |
| 112 | <td align="right" valign="top" |
| 113 | ><span class="options">[<a href="#section-Functions" |
| 114 | class="privatelink" onclick="toggle_private();" |
| 115 | >hide private</a>]</span></td> |
| 116 | </tr> |
| 117 | </table> |
| 118 | </td> |
| 119 | </tr> |
| 120 | <tr> |
| 121 | <td width="15%" align="right" valign="top" class="summary"> |
| 122 | <span class="summary-type"> </span> |
| 123 | </td><td class="summary"> |
| 124 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 125 | <tr> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 126 | <td><span class="summary-sig"><a href="oauth2client.tools-module.html#run_flow" class="summary-sig-name">run_flow</a>(<span class="summary-sig-arg">flow</span>, |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 127 | <span class="summary-sig-arg">storage</span>, |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 128 | <span class="summary-sig-arg">flags</span>, |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 129 | <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>)</span><br /> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 130 | Core code for a command-line application.</td> |
| 131 | <td align="right" valign="top"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 132 | <span class="codelink"><a href="oauth2client.tools-pysrc.html#run_flow">source code</a></span> |
| 133 | |
| 134 | </td> |
| 135 | </tr> |
| 136 | </table> |
| 137 | |
| 138 | </td> |
| 139 | </tr> |
| 140 | <tr> |
| 141 | <td width="15%" align="right" valign="top" class="summary"> |
| 142 | <span class="summary-type"> </span> |
| 143 | </td><td class="summary"> |
| 144 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 145 | <tr> |
| 146 | <td><span class="summary-sig"><a name="message_if_missing"></a><span class="summary-sig-name">message_if_missing</span>(<span class="summary-sig-arg">filename</span>)</span><br /> |
| 147 | Helpful message to display if the CLIENT_SECRETS file is missing.</td> |
| 148 | <td align="right" valign="top"> |
| 149 | <span class="codelink"><a href="oauth2client.tools-pysrc.html#message_if_missing">source code</a></span> |
| 150 | |
| 151 | </td> |
| 152 | </tr> |
| 153 | </table> |
| 154 | |
| 155 | </td> |
| 156 | </tr> |
| 157 | <tr> |
| 158 | <td width="15%" align="right" valign="top" class="summary"> |
| 159 | <span class="summary-type"> </span> |
| 160 | </td><td class="summary"> |
| 161 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 162 | <tr> |
| 163 | <td><span class="summary-sig"><a name="run"></a><span class="summary-sig-name">run</span>(<span class="summary-sig-arg">*args</span>, |
| 164 | <span class="summary-sig-arg">**kwargs</span>)</span></td> |
| 165 | <td align="right" valign="top"> |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 166 | <span class="codelink"><a href="oauth2client.tools-pysrc.html#run">source code</a></span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 167 | |
| 168 | </td> |
| 169 | </tr> |
| 170 | </table> |
| 171 | |
| 172 | </td> |
| 173 | </tr> |
| 174 | </table> |
| 175 | <!-- ==================== VARIABLES ==================== --> |
| 176 | <a name="section-Variables"></a> |
| 177 | <table class="summary" border="1" cellpadding="3" |
| 178 | cellspacing="0" width="100%" bgcolor="white"> |
| 179 | <tr bgcolor="#70b0f0" class="table-header"> |
| 180 | <td colspan="2" class="table-header"> |
| 181 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 182 | <tr valign="top"> |
| 183 | <td align="left"><span class="table-header">Variables</span></td> |
| 184 | <td align="right" valign="top" |
| 185 | ><span class="options">[<a href="#section-Variables" |
| 186 | class="privatelink" onclick="toggle_private();" |
| 187 | >hide private</a>]</span></td> |
| 188 | </tr> |
| 189 | </table> |
| 190 | </td> |
| 191 | </tr> |
| 192 | <tr class="private"> |
| 193 | <td width="15%" align="right" valign="top" class="summary"> |
| 194 | <span class="summary-type"> </span> |
| 195 | </td><td class="summary"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 196 | <a href="oauth2client.tools-module.html#_CLIENT_SECRETS_MESSAGE" class="summary-name" onclick="show_private();">_CLIENT_SECRETS_MESSAGE</a> = <code title=""""WARNING: Please configure OAuth 2.0 |
| 197 | |
| 198 | To make this sample run you will need to populate the client_secrets.j\ |
| 199 | son file |
| 200 | found at: |
| 201 | |
| 202 | %s |
| 203 | |
| 204 | ...">"""WARNING: Please configure OAuth <code class="variable-ellipsis">...</code></code> |
| 205 | </td> |
| 206 | </tr> |
| 207 | <tr> |
| 208 | <td width="15%" align="right" valign="top" class="summary"> |
| 209 | <span class="summary-type"> </span> |
| 210 | </td><td class="summary"> |
| 211 | <a name="argparser"></a><span class="summary-name">argparser</span> = <code title="argparse.ArgumentParser(add_help= False)">argparse.ArgumentParser(add_help= False)</code> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 212 | </td> |
| 213 | </tr> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 214 | </table> |
| 215 | <!-- ==================== FUNCTION DETAILS ==================== --> |
| 216 | <a name="section-FunctionDetails"></a> |
| 217 | <table class="details" border="1" cellpadding="3" |
| 218 | cellspacing="0" width="100%" bgcolor="white"> |
| 219 | <tr bgcolor="#70b0f0" class="table-header"> |
| 220 | <td colspan="2" class="table-header"> |
| 221 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 222 | <tr valign="top"> |
| 223 | <td align="left"><span class="table-header">Function Details</span></td> |
| 224 | <td align="right" valign="top" |
| 225 | ><span class="options">[<a href="#section-FunctionDetails" |
| 226 | class="privatelink" onclick="toggle_private();" |
| 227 | >hide private</a>]</span></td> |
| 228 | </tr> |
| 229 | </table> |
| 230 | </td> |
| 231 | </tr> |
| 232 | </table> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 233 | <a name="run_flow"></a> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 234 | <div> |
| 235 | <table class="details" border="1" cellpadding="3" |
| 236 | cellspacing="0" width="100%" bgcolor="white"> |
| 237 | <tr><td> |
| 238 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 239 | <tr valign="top"><td> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 240 | <h3 class="epydoc"><span class="sig"><span class="sig-name">run_flow</span>(<span class="sig-arg">flow</span>, |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 241 | <span class="sig-arg">storage</span>, |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 242 | <span class="sig-arg">flags</span>, |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 243 | <span class="sig-arg">http</span>=<span class="sig-default">None</span>)</span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 244 | </h3> |
| 245 | </td><td align="right" valign="top" |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 246 | ><span class="codelink"><a href="oauth2client.tools-pysrc.html#run_flow">source code</a></span> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 247 | </td> |
| 248 | </tr></table> |
| 249 | |
| 250 | <pre class="literalblock"> |
| 251 | Core code for a command-line application. |
| 252 | |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 253 | The run() function is called from your application and runs through all the |
| 254 | steps to obtain credentials. It takes a Flow argument and attempts to open an |
| 255 | authorization server page in the user's default web browser. The server asks |
| 256 | the user to grant your application access to the user's data. If the user |
| 257 | grants access, the run() function returns new credentials. The new credentials |
| 258 | are also stored in the Storage argument, which updates the file associated |
| 259 | with the Storage object. |
| 260 | |
| 261 | It presumes it is run from a command-line application and supports the |
| 262 | following flags: |
| 263 | |
Joe Gregorio | b2cdd80 | 2012-11-06 12:08:06 -0500 | [diff] [blame] | 264 | --auth_host_name: Host name to use when running a local web server |
| 265 | to handle redirects during OAuth authorization. |
| 266 | (default: 'localhost') |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 267 | |
Joe Gregorio | b2cdd80 | 2012-11-06 12:08:06 -0500 | [diff] [blame] | 268 | --auth_host_port: Port to use when running a local web server to handle |
| 269 | redirects during OAuth authorization.; |
| 270 | repeat this option to specify a list of values |
| 271 | (default: '[8080, 8090]') |
| 272 | (an integer) |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 273 | |
Joe Gregorio | b2cdd80 | 2012-11-06 12:08:06 -0500 | [diff] [blame] | 274 | --[no]auth_local_webserver: Run a local web server to handle redirects |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 275 | during OAuth authorization. |
Joe Gregorio | b2cdd80 | 2012-11-06 12:08:06 -0500 | [diff] [blame] | 276 | (default: 'true') |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 277 | |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 278 | The tools module defines an ArgumentParser the already contains the flag |
| 279 | definitions that run() requires. You can pass that ArgumentParser to your |
| 280 | ArgumentParser constructor: |
| 281 | |
| 282 | parser = argparse.ArgumentParser(description=__doc__, |
| 283 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 284 | parents=[tools.run_parser]) |
| 285 | flags = parser.parse_args(argv) |
Joe Gregorio | 5350efb | 2012-10-24 08:54:11 -0400 | [diff] [blame] | 286 | |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 287 | Args: |
| 288 | flow: Flow, an OAuth 2.0 Flow to step through. |
| 289 | storage: Storage, a Storage to store the credential in. |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 290 | flags: argparse.ArgumentParser, the command-line flags. |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 291 | http: An instance of httplib2.Http.request |
| 292 | or something that acts like it. |
| 293 | |
| 294 | Returns: |
| 295 | Credentials, the obtained credential. |
| 296 | |
| 297 | </pre> |
| 298 | <dl class="fields"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 299 | <dt>Decorators:</dt> |
| 300 | <dd><ul class="nomargin-top"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 301 | <li><code>@util.positional(3)</code></li> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 302 | </ul></dd> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 303 | </dl> |
| 304 | </td></tr></table> |
| 305 | </div> |
| 306 | <br /> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 307 | <!-- ==================== VARIABLES DETAILS ==================== --> |
| 308 | <a name="section-VariablesDetails"></a> |
| 309 | <table class="details" border="1" cellpadding="3" |
| 310 | cellspacing="0" width="100%" bgcolor="white"> |
| 311 | <tr bgcolor="#70b0f0" class="table-header"> |
| 312 | <td colspan="2" class="table-header"> |
| 313 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 314 | <tr valign="top"> |
| 315 | <td align="left"><span class="table-header">Variables Details</span></td> |
| 316 | <td align="right" valign="top" |
| 317 | ><span class="options">[<a href="#section-VariablesDetails" |
| 318 | class="privatelink" onclick="toggle_private();" |
| 319 | >hide private</a>]</span></td> |
| 320 | </tr> |
| 321 | </table> |
| 322 | </td> |
| 323 | </tr> |
| 324 | </table> |
| 325 | <a name="_CLIENT_SECRETS_MESSAGE"></a> |
| 326 | <div class="private"> |
| 327 | <table class="details" border="1" cellpadding="3" |
| 328 | cellspacing="0" width="100%" bgcolor="white"> |
| 329 | <tr><td> |
| 330 | <h3 class="epydoc">_CLIENT_SECRETS_MESSAGE</h3> |
| 331 | |
| 332 | <dl class="fields"> |
| 333 | </dl> |
| 334 | <dl class="fields"> |
| 335 | <dt>Value:</dt> |
| 336 | <dd><table><tr><td><pre class="variable"> |
| 337 | """WARNING: Please configure OAuth 2.0 |
| 338 | |
| 339 | To make this sample run you will need to populate the client_secrets.j<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span> |
| 340 | son file |
| 341 | found at: |
| 342 | |
| 343 | %s |
| 344 | |
| 345 | <code class="variable-ellipsis">...</code> |
| 346 | </pre></td></tr></table> |
| 347 | </dd> |
| 348 | </dl> |
| 349 | </td></tr></table> |
| 350 | </div> |
| 351 | <br /> |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 352 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 353 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 354 | bgcolor="#a0c0ff" cellspacing="0"> |
| 355 | <tr valign="middle"> |
| 356 | |
| 357 | <!-- Tree link --> |
| 358 | <th> <a |
| 359 | href="module-tree.html">Trees</a> </th> |
| 360 | |
| 361 | <!-- Index link --> |
| 362 | <th> <a |
| 363 | href="identifier-index.html">Indices</a> </th> |
| 364 | |
| 365 | <!-- Help link --> |
| 366 | <th> <a |
| 367 | href="help.html">Help</a> </th> |
| 368 | |
| 369 | <th class="navbar" width="100%"></th> |
| 370 | </tr> |
| 371 | </table> |
| 372 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 373 | <tr> |
| 374 | <td align="left" class="footer"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 375 | Generated by Epydoc 3.0.1 on Tue Aug 6 12:16:42 2013 |
Joe Gregorio | 5dc0f5c | 2012-06-05 13:34:31 -0400 | [diff] [blame] | 376 | </td> |
| 377 | <td align="right" class="footer"> |
| 378 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 379 | >http://epydoc.sourceforge.net</a> |
| 380 | </td> |
| 381 | </tr> |
| 382 | </table> |
| 383 | |
| 384 | <script type="text/javascript"> |
| 385 | <!-- |
| 386 | // Private objects are initially displayed (because if |
| 387 | // javascript is turned off then we want them to be |
| 388 | // visible); but by default, we want to hide them. So hide |
| 389 | // them unless we have a cookie that says to show them. |
| 390 | checkCookie(); |
| 391 | // --> |
| 392 | </script> |
| 393 | </body> |
| 394 | </html> |