Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -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>apiclient.sample_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="apiclient-module.html">Package apiclient</a> :: |
| 38 | Module sample_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="apiclient.sample_tools-pysrc.html" |
| 49 | target="_top">no frames</a>]</span></td></tr> |
| 50 | </table> |
| 51 | </td> |
| 52 | </tr> |
| 53 | </table> |
| 54 | <h1 class="epydoc">Source Code for <a href="apiclient.sample_tools-module.html">Module apiclient.sample_tools</a></h1> |
| 55 | <pre class="py-src"> |
| 56 | <a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-comment"># Copyright (C) 2013 Google Inc.</tt> </tt> |
| 57 | <a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt> |
| 58 | <a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-comment"># Licensed under the Apache License, Version 2.0 (the "License");</tt> </tt> |
| 59 | <a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-comment"># you may not use this file except in compliance with the License.</tt> </tt> |
| 60 | <a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-comment"># You may obtain a copy of the License at</tt> </tt> |
| 61 | <a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt> |
| 62 | <a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-comment"># http://www.apache.org/licenses/LICENSE-2.0</tt> </tt> |
| 63 | <a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt> |
| 64 | <a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-comment"># Unless required by applicable law or agreed to in writing, software</tt> </tt> |
| 65 | <a name="L10"></a><tt class="py-lineno">10</tt> <tt class="py-line"><tt class="py-comment"># distributed under the License is distributed on an "AS IS" BASIS,</tt> </tt> |
| 66 | <a name="L11"></a><tt class="py-lineno">11</tt> <tt class="py-line"><tt class="py-comment"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</tt> </tt> |
| 67 | <a name="L12"></a><tt class="py-lineno">12</tt> <tt class="py-line"><tt class="py-comment"># See the License for the specific language governing permissions and</tt> </tt> |
| 68 | <a name="L13"></a><tt class="py-lineno">13</tt> <tt class="py-line"><tt class="py-comment"># limitations under the License.</tt> </tt> |
| 69 | <a name="L14"></a><tt class="py-lineno">14</tt> <tt class="py-line"> </tt> |
| 70 | <a name="L15"></a><tt class="py-lineno">15</tt> <tt class="py-line"><tt class="py-docstring">"""Utilities for making samples.</tt> </tt> |
| 71 | <a name="L16"></a><tt class="py-lineno">16</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt> |
| 72 | <a name="L17"></a><tt class="py-lineno">17</tt> <tt class="py-line"><tt class="py-docstring">Consolidates a lot of code commonly repeated in sample applications.</tt> </tt> |
| 73 | <a name="L18"></a><tt class="py-lineno">18</tt> <tt class="py-line"><tt class="py-docstring">"""</tt> </tt> |
| 74 | <a name="L19"></a><tt class="py-lineno">19</tt> <tt class="py-line"> </tt> |
| 75 | <a name="L20"></a><tt class="py-lineno">20</tt> <tt class="py-line"><tt class="py-name">__author__</tt> <tt class="py-op">=</tt> <tt class="py-string">'jcgregorio@google.com (Joe Gregorio)'</tt> </tt> |
| 76 | <a name="L21"></a><tt class="py-lineno">21</tt> <tt class="py-line"><tt class="py-name">__all__</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'init'</tt><tt class="py-op">]</tt> </tt> |
| 77 | <a name="L22"></a><tt class="py-lineno">22</tt> <tt class="py-line"> </tt> |
| 78 | <a name="L23"></a><tt class="py-lineno">23</tt> <tt class="py-line"> </tt> |
| 79 | <a name="L24"></a><tt class="py-lineno">24</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">argparse</tt> </tt> |
| 80 | <a name="L25"></a><tt class="py-lineno">25</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">httplib2</tt> </tt> |
| 81 | <a name="L26"></a><tt class="py-lineno">26</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">os</tt> </tt> |
| 82 | <a name="L27"></a><tt class="py-lineno">27</tt> <tt class="py-line"> </tt> |
| 83 | <a name="L28"></a><tt class="py-lineno">28</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package apiclient=apiclient-module.html"><a title="apiclient" class="py-name" href="#" onclick="return doclink('link-0', 'apiclient', 'link-0');">apiclient</a></tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Module apiclient.discovery=apiclient.discovery-module.html"><a title="apiclient.discovery" class="py-name" href="#" onclick="return doclink('link-1', 'discovery', 'link-1');">discovery</a></tt> </tt> |
| 84 | <a name="L29"></a><tt class="py-lineno">29</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-2" class="py-name" targets="Package oauth2client=oauth2client-module.html"><a title="oauth2client" class="py-name" href="#" onclick="return doclink('link-2', 'oauth2client', 'link-2');">oauth2client</a></tt> <tt class="py-keyword">import</tt> <tt id="link-3" class="py-name" targets="Module oauth2client.client=oauth2client.client-module.html"><a title="oauth2client.client" class="py-name" href="#" onclick="return doclink('link-3', 'client', 'link-3');">client</a></tt> </tt> |
| 85 | <a name="L30"></a><tt class="py-lineno">30</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-4" class="py-name"><a title="oauth2client" class="py-name" href="#" onclick="return doclink('link-4', 'oauth2client', 'link-2');">oauth2client</a></tt> <tt class="py-keyword">import</tt> <tt id="link-5" class="py-name" targets="Module oauth2client.file=oauth2client.file-module.html"><a title="oauth2client.file" class="py-name" href="#" onclick="return doclink('link-5', 'file', 'link-5');">file</a></tt> </tt> |
| 86 | <a name="L31"></a><tt class="py-lineno">31</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-6" class="py-name"><a title="oauth2client" class="py-name" href="#" onclick="return doclink('link-6', 'oauth2client', 'link-2');">oauth2client</a></tt> <tt class="py-keyword">import</tt> <tt id="link-7" class="py-name" targets="Module oauth2client.tools=oauth2client.tools-module.html"><a title="oauth2client.tools" class="py-name" href="#" onclick="return doclink('link-7', 'tools', 'link-7');">tools</a></tt> </tt> |
| 87 | <a name="L32"></a><tt class="py-lineno">32</tt> <tt class="py-line"> </tt> |
| 88 | <a name="L33"></a><tt class="py-lineno">33</tt> <tt class="py-line"> </tt> |
| 89 | <a name="init"></a><div id="init-def"><a name="L34"></a><tt class="py-lineno">34</tt> <a class="py-toggle" href="#" id="init-toggle" onclick="return toggle('init');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="apiclient.sample_tools-module.html#init">init</a><tt class="py-op">(</tt><tt class="py-param">argv</tt><tt class="py-op">,</tt> <tt class="py-param">name</tt><tt class="py-op">,</tt> <tt class="py-param">version</tt><tt class="py-op">,</tt> <tt class="py-param">doc</tt><tt class="py-op">,</tt> <tt class="py-param">filename</tt><tt class="py-op">,</tt> <tt class="py-param">scope</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">parents</tt><tt class="py-op">=</tt><tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt> |
| 90 | </div><div id="init-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="init-expanded"><a name="L35"></a><tt class="py-lineno">35</tt> <tt class="py-line"> <tt class="py-docstring">"""A common initialization routine for samples.</tt> </tt> |
| 91 | <a name="L36"></a><tt class="py-lineno">36</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt> |
| 92 | <a name="L37"></a><tt class="py-lineno">37</tt> <tt class="py-line"><tt class="py-docstring"> Many of the sample applications do the same initialization, which has now</tt> </tt> |
| 93 | <a name="L38"></a><tt class="py-lineno">38</tt> <tt class="py-line"><tt class="py-docstring"> been consolidated into this function. This function uses common idioms found</tt> </tt> |
| 94 | <a name="L39"></a><tt class="py-lineno">39</tt> <tt class="py-line"><tt class="py-docstring"> in almost all the samples, i.e. for an API with name 'apiname', the</tt> </tt> |
| 95 | <a name="L40"></a><tt class="py-lineno">40</tt> <tt class="py-line"><tt class="py-docstring"> credentials are stored in a file named apiname.dat, and the</tt> </tt> |
| 96 | <a name="L41"></a><tt class="py-lineno">41</tt> <tt class="py-line"><tt class="py-docstring"> client_secrets.json file is stored in the same directory as the application</tt> </tt> |
| 97 | <a name="L42"></a><tt class="py-lineno">42</tt> <tt class="py-line"><tt class="py-docstring"> main file.</tt> </tt> |
| 98 | <a name="L43"></a><tt class="py-lineno">43</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt> |
| 99 | <a name="L44"></a><tt class="py-lineno">44</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt> |
| 100 | <a name="L45"></a><tt class="py-lineno">45</tt> <tt class="py-line"><tt class="py-docstring"> argv: list of string, the command-line parameters of the application.</tt> </tt> |
| 101 | <a name="L46"></a><tt class="py-lineno">46</tt> <tt class="py-line"><tt class="py-docstring"> name: string, name of the API.</tt> </tt> |
| 102 | <a name="L47"></a><tt class="py-lineno">47</tt> <tt class="py-line"><tt class="py-docstring"> version: string, version of the API.</tt> </tt> |
| 103 | <a name="L48"></a><tt class="py-lineno">48</tt> <tt class="py-line"><tt class="py-docstring"> doc: string, description of the application. Usually set to __doc__.</tt> </tt> |
| 104 | <a name="L49"></a><tt class="py-lineno">49</tt> <tt class="py-line"><tt class="py-docstring"> file: string, filename of the application. Usually set to __file__.</tt> </tt> |
| 105 | <a name="L50"></a><tt class="py-lineno">50</tt> <tt class="py-line"><tt class="py-docstring"> parents: list of argparse.ArgumentParser, additional command-line flags.</tt> </tt> |
| 106 | <a name="L51"></a><tt class="py-lineno">51</tt> <tt class="py-line"><tt class="py-docstring"> scope: string, The OAuth scope used.</tt> </tt> |
| 107 | <a name="L52"></a><tt class="py-lineno">52</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt> |
| 108 | <a name="L53"></a><tt class="py-lineno">53</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt> |
| 109 | <a name="L54"></a><tt class="py-lineno">54</tt> <tt class="py-line"><tt class="py-docstring"> A tuple of (service, flags), where service is the service object and flags</tt> </tt> |
| 110 | <a name="L55"></a><tt class="py-lineno">55</tt> <tt class="py-line"><tt class="py-docstring"> is the parsed command-line flags.</tt> </tt> |
| 111 | <a name="L56"></a><tt class="py-lineno">56</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt> |
| 112 | <a name="L57"></a><tt class="py-lineno">57</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">scope</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt> |
| 113 | <a name="L58"></a><tt class="py-lineno">58</tt> <tt class="py-line"> <tt class="py-name">scope</tt> <tt class="py-op">=</tt> <tt class="py-string">'https://www.googleapis.com/auth/'</tt> <tt class="py-op">+</tt> <tt class="py-name">name</tt> </tt> |
| 114 | <a name="L59"></a><tt class="py-lineno">59</tt> <tt class="py-line"> </tt> |
| 115 | <a name="L60"></a><tt class="py-lineno">60</tt> <tt class="py-line"> <tt class="py-comment"># Parser command-line arguments.</tt> </tt> |
| 116 | <a name="L61"></a><tt class="py-lineno">61</tt> <tt class="py-line"> <tt class="py-name">parent_parsers</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt id="link-8" class="py-name"><a title="oauth2client.tools" class="py-name" href="#" onclick="return doclink('link-8', 'tools', 'link-7');">tools</a></tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Variable oauth2client.tools.argparser=oauth2client.tools-module.html#argparser"><a title="oauth2client.tools.argparser" class="py-name" href="#" onclick="return doclink('link-9', 'argparser', 'link-9');">argparser</a></tt><tt class="py-op">]</tt> </tt> |
| 117 | <a name="L62"></a><tt class="py-lineno">62</tt> <tt class="py-line"> <tt class="py-name">parent_parsers</tt><tt class="py-op">.</tt><tt class="py-name">extend</tt><tt class="py-op">(</tt><tt class="py-name">parents</tt><tt class="py-op">)</tt> </tt> |
| 118 | <a name="L63"></a><tt class="py-lineno">63</tt> <tt class="py-line"> <tt class="py-name">parser</tt> <tt class="py-op">=</tt> <tt class="py-name">argparse</tt><tt class="py-op">.</tt><tt class="py-name">ArgumentParser</tt><tt class="py-op">(</tt> </tt> |
| 119 | <a name="L64"></a><tt class="py-lineno">64</tt> <tt class="py-line"> <tt class="py-name">description</tt><tt class="py-op">=</tt><tt class="py-name">doc</tt><tt class="py-op">,</tt> </tt> |
| 120 | <a name="L65"></a><tt class="py-lineno">65</tt> <tt class="py-line"> <tt class="py-name">formatter_class</tt><tt class="py-op">=</tt><tt class="py-name">argparse</tt><tt class="py-op">.</tt><tt class="py-name">RawDescriptionHelpFormatter</tt><tt class="py-op">,</tt> </tt> |
| 121 | <a name="L66"></a><tt class="py-lineno">66</tt> <tt class="py-line"> <tt class="py-name">parents</tt><tt class="py-op">=</tt><tt class="py-name">parent_parsers</tt><tt class="py-op">)</tt> </tt> |
| 122 | <a name="L67"></a><tt class="py-lineno">67</tt> <tt class="py-line"> <tt class="py-name">flags</tt> <tt class="py-op">=</tt> <tt class="py-name">parser</tt><tt class="py-op">.</tt><tt class="py-name">parse_args</tt><tt class="py-op">(</tt><tt class="py-name">argv</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt> |
| 123 | <a name="L68"></a><tt class="py-lineno">68</tt> <tt class="py-line"> </tt> |
| 124 | <a name="L69"></a><tt class="py-lineno">69</tt> <tt class="py-line"> <tt class="py-comment"># Name of a file containing the OAuth 2.0 information for this</tt> </tt> |
| 125 | <a name="L70"></a><tt class="py-lineno">70</tt> <tt class="py-line"> <tt class="py-comment"># application, including client_id and client_secret, which are found</tt> </tt> |
| 126 | <a name="L71"></a><tt class="py-lineno">71</tt> <tt class="py-line"> <tt class="py-comment"># on the API Access tab on the Google APIs</tt> </tt> |
| 127 | <a name="L72"></a><tt class="py-lineno">72</tt> <tt class="py-line"> <tt class="py-comment"># Console <http://code.google.com/apis/console>.</tt> </tt> |
| 128 | <a name="L73"></a><tt class="py-lineno">73</tt> <tt class="py-line"> <tt class="py-name">client_secrets</tt> <tt class="py-op">=</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">.</tt><tt class="py-name">dirname</tt><tt class="py-op">(</tt><tt id="link-10" class="py-name" targets="Method oauth2client.locked_file.LockedFile.filename()=oauth2client.locked_file.LockedFile-class.html#filename,Method oauth2client.locked_file._Opener.filename()=oauth2client.locked_file._Opener-class.html#filename"><a title="oauth2client.locked_file.LockedFile.filename |
| 129 | oauth2client.locked_file._Opener.filename" class="py-name" href="#" onclick="return doclink('link-10', 'filename', 'link-10');">filename</a></tt><tt class="py-op">)</tt><tt class="py-op">,</tt> </tt> |
| 130 | <a name="L74"></a><tt class="py-lineno">74</tt> <tt class="py-line"> <tt class="py-string">'client_secrets.json'</tt><tt class="py-op">)</tt> </tt> |
| 131 | <a name="L75"></a><tt class="py-lineno">75</tt> <tt class="py-line"> </tt> |
| 132 | <a name="L76"></a><tt class="py-lineno">76</tt> <tt class="py-line"> <tt class="py-comment"># Set up a Flow object to be used if we need to authenticate.</tt> </tt> |
| 133 | <a name="L77"></a><tt class="py-lineno">77</tt> <tt class="py-line"> <tt id="link-11" class="py-name" targets="Variable oauth2client.appengine.OAuth2Decorator.flow=oauth2client.appengine.OAuth2Decorator-class.html#flow"><a title="oauth2client.appengine.OAuth2Decorator.flow" class="py-name" href="#" onclick="return doclink('link-11', 'flow', 'link-11');">flow</a></tt> <tt class="py-op">=</tt> <tt id="link-12" class="py-name"><a title="oauth2client.client" class="py-name" href="#" onclick="return doclink('link-12', 'client', 'link-3');">client</a></tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Function oauth2client.client.flow_from_clientsecrets()=oauth2client.client-module.html#flow_from_clientsecrets"><a title="oauth2client.client.flow_from_clientsecrets" class="py-name" href="#" onclick="return doclink('link-13', 'flow_from_clientsecrets', 'link-13');">flow_from_clientsecrets</a></tt><tt class="py-op">(</tt><tt class="py-name">client_secrets</tt><tt class="py-op">,</tt> </tt> |
| 134 | <a name="L78"></a><tt class="py-lineno">78</tt> <tt class="py-line"> <tt class="py-name">scope</tt><tt class="py-op">=</tt><tt class="py-name">scope</tt><tt class="py-op">,</tt> </tt> |
| 135 | <a name="L79"></a><tt class="py-lineno">79</tt> <tt class="py-line"> <tt class="py-name">message</tt><tt class="py-op">=</tt><tt id="link-14" class="py-name"><a title="oauth2client.tools" class="py-name" href="#" onclick="return doclink('link-14', 'tools', 'link-7');">tools</a></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Function oauth2client.tools.message_if_missing()=oauth2client.tools-module.html#message_if_missing"><a title="oauth2client.tools.message_if_missing" class="py-name" href="#" onclick="return doclink('link-15', 'message_if_missing', 'link-15');">message_if_missing</a></tt><tt class="py-op">(</tt><tt class="py-name">client_secrets</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt> |
| 136 | <a name="L80"></a><tt class="py-lineno">80</tt> <tt class="py-line"> </tt> |
| 137 | <a name="L81"></a><tt class="py-lineno">81</tt> <tt class="py-line"> <tt class="py-comment"># Prepare credentials, and authorize HTTP object with them.</tt> </tt> |
| 138 | <a name="L82"></a><tt class="py-lineno">82</tt> <tt class="py-line"> <tt class="py-comment"># If the credentials don't exist or are invalid run through the native client</tt> </tt> |
| 139 | <a name="L83"></a><tt class="py-lineno">83</tt> <tt class="py-line"> <tt class="py-comment"># flow. The Storage object will ensure that if successful the good</tt> </tt> |
| 140 | <a name="L84"></a><tt class="py-lineno">84</tt> <tt class="py-line"> <tt class="py-comment"># credentials will get written back to a file.</tt> </tt> |
| 141 | <a name="L85"></a><tt class="py-lineno">85</tt> <tt class="py-line"> <tt class="py-name">storage</tt> <tt class="py-op">=</tt> <tt id="link-16" class="py-name"><a title="oauth2client.file" class="py-name" href="#" onclick="return doclink('link-16', 'file', 'link-5');">file</a></tt><tt class="py-op">.</tt><tt id="link-17" class="py-name" targets="Class oauth2client.client.Storage=oauth2client.client.Storage-class.html,Class oauth2client.django_orm.Storage=oauth2client.django_orm.Storage-class.html,Class oauth2client.file.Storage=oauth2client.file.Storage-class.html,Class oauth2client.keyring_storage.Storage=oauth2client.keyring_storage.Storage-class.html"><a title="oauth2client.client.Storage |
| 142 | oauth2client.django_orm.Storage |
| 143 | oauth2client.file.Storage |
| 144 | oauth2client.keyring_storage.Storage" class="py-name" href="#" onclick="return doclink('link-17', 'Storage', 'link-17');">Storage</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt> <tt class="py-op">+</tt> <tt class="py-string">'.dat'</tt><tt class="py-op">)</tt> </tt> |
| 145 | <a name="L86"></a><tt class="py-lineno">86</tt> <tt class="py-line"> <tt id="link-18" class="py-name" targets="Variable oauth2client.appengine.CredentialsModel.credentials=oauth2client.appengine.CredentialsModel-class.html#credentials,Variable oauth2client.appengine.CredentialsNDBModel.credentials=oauth2client.appengine.CredentialsNDBModel-class.html#credentials,Variable oauth2client.appengine.OAuth2Decorator.credentials=oauth2client.appengine.OAuth2Decorator-class.html#credentials"><a title="oauth2client.appengine.CredentialsModel.credentials |
| 146 | oauth2client.appengine.CredentialsNDBModel.credentials |
| 147 | oauth2client.appengine.OAuth2Decorator.credentials" class="py-name" href="#" onclick="return doclink('link-18', 'credentials', 'link-18');">credentials</a></tt> <tt class="py-op">=</tt> <tt class="py-name">storage</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name" targets="Method apiclient.schema.Schemas.get()=apiclient.schema.Schemas-class.html#get,Method oauth2client.client.MemoryCache.get()=oauth2client.client.MemoryCache-class.html#get,Method oauth2client.client.Storage.get()=oauth2client.client.Storage-class.html#get"><a title="apiclient.schema.Schemas.get |
| 148 | oauth2client.client.MemoryCache.get |
| 149 | oauth2client.client.Storage.get" class="py-name" href="#" onclick="return doclink('link-19', 'get', 'link-19');">get</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt> |
| 150 | <a name="L87"></a><tt class="py-lineno">87</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-20" class="py-name"><a title="oauth2client.appengine.CredentialsModel.credentials |
| 151 | oauth2client.appengine.CredentialsNDBModel.credentials |
| 152 | oauth2client.appengine.OAuth2Decorator.credentials" class="py-name" href="#" onclick="return doclink('link-20', 'credentials', 'link-18');">credentials</a></tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt> <tt class="py-keyword">or</tt> <tt id="link-21" class="py-name"><a title="oauth2client.appengine.CredentialsModel.credentials |
| 153 | oauth2client.appengine.CredentialsNDBModel.credentials |
| 154 | oauth2client.appengine.OAuth2Decorator.credentials" class="py-name" href="#" onclick="return doclink('link-21', 'credentials', 'link-18');">credentials</a></tt><tt class="py-op">.</tt><tt class="py-name">invalid</tt><tt class="py-op">:</tt> </tt> |
| 155 | <a name="L88"></a><tt class="py-lineno">88</tt> <tt class="py-line"> <tt id="link-22" class="py-name"><a title="oauth2client.appengine.CredentialsModel.credentials |
| 156 | oauth2client.appengine.CredentialsNDBModel.credentials |
| 157 | oauth2client.appengine.OAuth2Decorator.credentials" class="py-name" href="#" onclick="return doclink('link-22', 'credentials', 'link-18');">credentials</a></tt> <tt class="py-op">=</tt> <tt id="link-23" class="py-name"><a title="oauth2client.tools" class="py-name" href="#" onclick="return doclink('link-23', 'tools', 'link-7');">tools</a></tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Function oauth2client.tools.run_flow()=oauth2client.tools-module.html#run_flow"><a title="oauth2client.tools.run_flow" class="py-name" href="#" onclick="return doclink('link-24', 'run_flow', 'link-24');">run_flow</a></tt><tt class="py-op">(</tt><tt id="link-25" class="py-name"><a title="oauth2client.appengine.OAuth2Decorator.flow" class="py-name" href="#" onclick="return doclink('link-25', 'flow', 'link-11');">flow</a></tt><tt class="py-op">,</tt> <tt class="py-name">storage</tt><tt class="py-op">,</tt> <tt class="py-name">flags</tt><tt class="py-op">)</tt> </tt> |
| 158 | <a name="L89"></a><tt class="py-lineno">89</tt> <tt class="py-line"> <tt id="link-26" class="py-name" targets="Module apiclient.http=apiclient.http-module.html,Method oauth2client.appengine.OAuth2Decorator.http()=oauth2client.appengine.OAuth2Decorator-class.html#http"><a title="apiclient.http |
| 159 | oauth2client.appengine.OAuth2Decorator.http" class="py-name" href="#" onclick="return doclink('link-26', 'http', 'link-26');">http</a></tt> <tt class="py-op">=</tt> <tt id="link-27" class="py-name"><a title="oauth2client.appengine.CredentialsModel.credentials |
| 160 | oauth2client.appengine.CredentialsNDBModel.credentials |
| 161 | oauth2client.appengine.OAuth2Decorator.credentials" class="py-name" href="#" onclick="return doclink('link-27', 'credentials', 'link-18');">credentials</a></tt><tt class="py-op">.</tt><tt id="link-28" class="py-name" targets="Method oauth2client.client.Credentials.authorize()=oauth2client.client.Credentials-class.html#authorize,Method oauth2client.client.OAuth2Credentials.authorize()=oauth2client.client.OAuth2Credentials-class.html#authorize"><a title="oauth2client.client.Credentials.authorize |
| 162 | oauth2client.client.OAuth2Credentials.authorize" class="py-name" href="#" onclick="return doclink('link-28', 'authorize', 'link-28');">authorize</a></tt><tt class="py-op">(</tt><tt id="link-29" class="py-name"><a title="apiclient.http |
| 163 | oauth2client.appengine.OAuth2Decorator.http" class="py-name" href="#" onclick="return doclink('link-29', 'http', 'link-26');">http</a></tt> <tt class="py-op">=</tt> <tt class="py-name">httplib2</tt><tt class="py-op">.</tt><tt class="py-name">Http</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt> |
| 164 | <a name="L90"></a><tt class="py-lineno">90</tt> <tt class="py-line"> </tt> |
| 165 | <a name="L91"></a><tt class="py-lineno">91</tt> <tt class="py-line"> <tt class="py-comment"># Construct a service object via the discovery service.</tt> </tt> |
| 166 | <a name="L92"></a><tt class="py-lineno">92</tt> <tt class="py-line"> <tt class="py-name">service</tt> <tt class="py-op">=</tt> <tt id="link-30" class="py-name"><a title="apiclient.discovery" class="py-name" href="#" onclick="return doclink('link-30', 'discovery', 'link-1');">discovery</a></tt><tt class="py-op">.</tt><tt id="link-31" class="py-name" targets="Function apiclient.discovery.build()=apiclient.discovery-module.html#build"><a title="apiclient.discovery.build" class="py-name" href="#" onclick="return doclink('link-31', 'build', 'link-31');">build</a></tt><tt class="py-op">(</tt><tt class="py-name">name</tt><tt class="py-op">,</tt> <tt class="py-name">version</tt><tt class="py-op">,</tt> <tt id="link-32" class="py-name"><a title="apiclient.http |
| 167 | oauth2client.appengine.OAuth2Decorator.http" class="py-name" href="#" onclick="return doclink('link-32', 'http', 'link-26');">http</a></tt><tt class="py-op">=</tt><tt id="link-33" class="py-name"><a title="apiclient.http |
| 168 | oauth2client.appengine.OAuth2Decorator.http" class="py-name" href="#" onclick="return doclink('link-33', 'http', 'link-26');">http</a></tt><tt class="py-op">)</tt> </tt> |
| 169 | <a name="L93"></a><tt class="py-lineno">93</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">service</tt><tt class="py-op">,</tt> <tt class="py-name">flags</tt><tt class="py-op">)</tt> </tt> |
| 170 | </div><a name="L94"></a><tt class="py-lineno">94</tt> <tt class="py-line"> </tt><script type="text/javascript"> |
| 171 | <!-- |
| 172 | expandto(location.href); |
| 173 | // --> |
| 174 | </script> |
| 175 | </pre> |
| 176 | <br /> |
| 177 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 178 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 179 | bgcolor="#a0c0ff" cellspacing="0"> |
| 180 | <tr valign="middle"> |
| 181 | |
| 182 | <!-- Tree link --> |
| 183 | <th> <a |
| 184 | href="module-tree.html">Trees</a> </th> |
| 185 | |
| 186 | <!-- Index link --> |
| 187 | <th> <a |
| 188 | href="identifier-index.html">Indices</a> </th> |
| 189 | |
| 190 | <!-- Help link --> |
| 191 | <th> <a |
| 192 | href="help.html">Help</a> </th> |
| 193 | |
| 194 | <th class="navbar" width="100%"></th> |
| 195 | </tr> |
| 196 | </table> |
| 197 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 198 | <tr> |
| 199 | <td align="left" class="footer"> |
| 200 | Generated by Epydoc 3.0.1 on Tue Aug 6 12:16:47 2013 |
| 201 | </td> |
| 202 | <td align="right" class="footer"> |
| 203 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 204 | >http://epydoc.sourceforge.net</a> |
| 205 | </td> |
| 206 | </tr> |
| 207 | </table> |
| 208 | |
| 209 | <script type="text/javascript"> |
| 210 | <!-- |
| 211 | // Private objects are initially displayed (because if |
| 212 | // javascript is turned off then we want them to be |
| 213 | // visible); but by default, we want to hide them. So hide |
| 214 | // them unless we have a cookie that says to show them. |
| 215 | checkCookie(); |
| 216 | // --> |
| 217 | </script> |
| 218 | </body> |
| 219 | </html> |