Finish adding Storage to the OAuth 1.0 client and updated all examples to use file.Storage. No more three_legged_dance.py files anywhere.
This commit is contained in:
		| @@ -76,12 +76,21 @@ class ClientRedirectHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |||||||
|     pass |     pass | ||||||
|  |  | ||||||
|  |  | ||||||
| def run(flow, filename): | def run(flow, storage): | ||||||
|   """Core code for a command-line application. |   """Core code for a command-line application. | ||||||
|  |  | ||||||
|  |   Args: | ||||||
|  |     flow: Flow, an OAuth 1.0 Flow to step through. | ||||||
|  |     storage: Storage, a Storage to store the credential in. | ||||||
|  |  | ||||||
|  |   Returns: | ||||||
|  |     Credentials, the obtained credential. | ||||||
|  |  | ||||||
|  |   Exceptions: | ||||||
|  |     RequestError: if step2 of the flow fails. | ||||||
|  |   Args: | ||||||
|   """ |   """ | ||||||
|   parser = OptionParser() |   parser = OptionParser() | ||||||
|   parser.add_option("-f", "--file", dest="filename", |  | ||||||
|       default=filename, help="write credentials to FILE", metavar="FILE") |  | ||||||
|   parser.add_option("-p", "--no_local_web_server", dest="localhost", |   parser.add_option("-p", "--no_local_web_server", dest="localhost", | ||||||
|       action="store_false", |       action="store_false", | ||||||
|       default=True, |       default=True, | ||||||
| @@ -134,9 +143,8 @@ def run(flow, filename): | |||||||
|   except RequestError: |   except RequestError: | ||||||
|     sys.exit('The authentication has failed.') |     sys.exit('The authentication has failed.') | ||||||
|  |  | ||||||
|   f = open(filename, 'w') |   storage.put(credentials) | ||||||
|   f.write(pickle.dumps(credentials)) |   credentials.set_store(storage.put) | ||||||
|   f.close() |  | ||||||
|   print "You have successfully authenticated." |   print "You have successfully authenticated." | ||||||
|  |  | ||||||
|   return credentials |   return credentials | ||||||
|   | |||||||
| @@ -28,9 +28,9 @@ class Storage(BaseStorage): | |||||||
|       f = open(self._filename, 'r') |       f = open(self._filename, 'r') | ||||||
|       credentials = pickle.loads(f.read()) |       credentials = pickle.loads(f.read()) | ||||||
|       f.close() |       f.close() | ||||||
|  |       credentials.set_store(self.put) | ||||||
|     except: |     except: | ||||||
|       credentials = None |       credentials = None | ||||||
|     credentials.set_store(self.put) |  | ||||||
|  |  | ||||||
|     return credentials |     return credentials | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.anyjson</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.anyjson</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/anyjson.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/anyjson.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/anyjson.py">/home/jcgregorio/projects/apiary/apiclient/anyjson.py</a></font></td></tr></table> | ||||||
|     <p><tt>Utility module to import a JSON module<br> |     <p><tt>Utility module to import a JSON module<br> | ||||||
|  <br> |  <br> | ||||||
| Hides all the messy details of exactly where<br> | Hides all the messy details of exactly where<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.contrib</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.contrib</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/contrib/__init__.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/contrib/__init__.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/contrib/__init__.py">/home/jcgregorio/projects/apiary/apiclient/contrib/__init__.py</a></font></td></tr></table> | ||||||
|     <p></p> |     <p></p> | ||||||
| <p> | <p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.discovery</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.discovery</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/discovery.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/discovery.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/discovery.py">/home/jcgregorio/projects/apiary/apiclient/discovery.py</a></font></td></tr></table> | ||||||
|     <p><tt>Client for discovery based APIs<br> |     <p><tt>Client for discovery based APIs<br> | ||||||
|  <br> |  <br> | ||||||
| A client library for Google's discovery based APIs.</tt></p> | A client library for Google's discovery based APIs.</tt></p> | ||||||
| @@ -34,7 +34,7 @@ A client library for Google's discovery based  | |||||||
| <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | ||||||
|      |      | ||||||
| <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | ||||||
| <td width="100%"><dl><dt><a name="-build"><strong>build</strong></a>(serviceName, version, http<font color="#909090">=None</font>, discoveryServiceUrl<font color="#909090">='https://www.googleapis.com/discovery/v0.2beta1/describe/{api}/{apiVersion}'</font>, developerKey<font color="#909090">=None</font>, model<font color="#909090">=<apiclient.model.JsonModel object></font>, requestBuilder<font color="#909090">=<class 'apiclient.http.HttpRequest'></font>)</dt><dd><tt>Construct a Resource for interacting with an API.<br> | <td width="100%"><dl><dt><a name="-build"><strong>build</strong></a>(serviceName, version, http<font color="#909090">=None</font>, discoveryServiceUrl<font color="#909090">='https://www.googleapis.com/discovery/v0.3/describe/{api}/{apiVersion}'</font>, developerKey<font color="#909090">=None</font>, model<font color="#909090">=<apiclient.model.JsonModel object></font>, requestBuilder<font color="#909090">=<class 'apiclient.http.HttpRequest'></font>)</dt><dd><tt>Construct a Resource for interacting with an API.<br> | ||||||
|  <br> |  <br> | ||||||
| Construct a Resource object for interacting with<br> | Construct a Resource object for interacting with<br> | ||||||
| an API. The serviceName and version are the<br> | an API. The serviceName and version are the<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.errors</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.errors</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/errors.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/errors.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/errors.py">/home/jcgregorio/projects/apiary/apiclient/errors.py</a></font></td></tr></table> | ||||||
|     <p><tt>Errors for the library.<br> |     <p><tt>Errors for the library.<br> | ||||||
|  <br> |  <br> | ||||||
| All exceptions defined by the library<br> | All exceptions defined by the library<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.appengine</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.appengine</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/appengine.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/appengine.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/ext/appengine.py">/home/jcgregorio/projects/apiary/apiclient/ext/appengine.py</a></font></td></tr></table> | ||||||
|     <p><tt>Utilities for Google App Engine<br> |     <p><tt>Utilities for Google App Engine<br> | ||||||
|  <br> |  <br> | ||||||
| Utilities for making it easier to use the<br> | Utilities for making it easier to use the<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.authtools</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.authtools</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/authtools.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/authtools.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/ext/authtools.py">/home/jcgregorio/projects/apiary/apiclient/ext/authtools.py</a></font></td></tr></table> | ||||||
|     <p><tt>Command-line tools for authenticating via OAuth 1.0<br> |     <p><tt>Command-line tools for authenticating via OAuth 1.0<br> | ||||||
|  <br> |  <br> | ||||||
| Do the OAuth 1.0 Three Legged Dance for<br> | Do the OAuth 1.0 Three Legged Dance for<br> | ||||||
| @@ -34,7 +34,18 @@ other example apps in the same directory.</tt></p> | |||||||
| <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | ||||||
|      |      | ||||||
| <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | ||||||
| <td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(flow, filename)</dt><dd><tt>Core code for a command-line application.</tt></dd></dl> | <td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(flow, storage)</dt><dd><tt>Core code for a command-line application.<br> | ||||||
|  |  <br> | ||||||
|  | Args:<br> | ||||||
|  |   flow: Flow, an OAuth 1.0 Flow to step through.<br> | ||||||
|  |   storage: Storage, a Storage to store the credential in.<br> | ||||||
|  |  <br> | ||||||
|  | Returns:<br> | ||||||
|  |   Credentials, the obtained credential.<br> | ||||||
|  |  <br> | ||||||
|  | Exceptions:<br> | ||||||
|  |   RequestError: if step2 of the flow fails.<br> | ||||||
|  | Args:</tt></dd></dl> | ||||||
| </td></tr></table><p> | </td></tr></table><p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| <tr bgcolor="#55aa55"> | <tr bgcolor="#55aa55"> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.django_orm</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.django_orm</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/django_orm.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/django_orm.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/ext/django_orm.py">/home/jcgregorio/projects/apiary/apiclient/ext/django_orm.py</a></font></td></tr></table> | ||||||
|     <p></p> |     <p></p> | ||||||
| <p> | <p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|   | |||||||
							
								
								
									
										89
									
								
								docs/apiclient.ext.file.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								docs/apiclient.ext.file.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | |||||||
|  |  | ||||||
|  | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | ||||||
|  | <html><head><title>Python: module apiclient.ext.file</title> | ||||||
|  | </head><body bgcolor="#f0f0f8"> | ||||||
|  |  | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | ||||||
|  | <tr bgcolor="#7799ee"> | ||||||
|  | <td valign=bottom> <br> | ||||||
|  | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.<a href="apiclient.ext.html"><font color="#ffffff">ext</font></a>.file</strong></big></big></font></td | ||||||
|  | ><td align=right valign=bottom | ||||||
|  | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/ext/file.py">/home/jcgregorio/projects/apiary/apiclient/ext/file.py</a></font></td></tr></table> | ||||||
|  |     <p><tt>Utilities for OAuth.<br> | ||||||
|  |  <br> | ||||||
|  | Utilities for making it easier to work with OAuth 1.0 credentials.</tt></p> | ||||||
|  | <p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#aa55cc"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> | ||||||
|  |      | ||||||
|  | <tr><td bgcolor="#aa55cc"><tt>      </tt></td><td> </td> | ||||||
|  | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="pickle.html">pickle</a><br> | ||||||
|  | </td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#ee77aa"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> | ||||||
|  |      | ||||||
|  | <tr><td bgcolor="#ee77aa"><tt>      </tt></td><td> </td> | ||||||
|  | <td width="100%"><dl> | ||||||
|  | <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#Storage">apiclient.oauth.Storage</a>(<a href="__builtin__.html#object">__builtin__.object</a>) | ||||||
|  | </font></dt><dd> | ||||||
|  | <dl> | ||||||
|  | <dt><font face="helvetica, arial"><a href="apiclient.ext.file.html#Storage">Storage</a> | ||||||
|  | </font></dt></dl> | ||||||
|  | </dd> | ||||||
|  | </dl> | ||||||
|  |  <p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#ffc8d8"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#000000" face="helvetica, arial"><a name="Storage">class <strong>Storage</strong></a>(<a href="apiclient.oauth.html#Storage">apiclient.oauth.Storage</a>)</font></td></tr> | ||||||
|  |      | ||||||
|  | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | ||||||
|  | <td colspan=2><tt>Store and retrieve a single credential to and from a file.<br> </tt></td></tr> | ||||||
|  | <tr><td> </td> | ||||||
|  | <td width="100%"><dl><dt>Method resolution order:</dt> | ||||||
|  | <dd><a href="apiclient.ext.file.html#Storage">Storage</a></dd> | ||||||
|  | <dd><a href="apiclient.oauth.html#Storage">apiclient.oauth.Storage</a></dd> | ||||||
|  | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> | ||||||
|  | </dl> | ||||||
|  | <hr> | ||||||
|  | Methods defined here:<br> | ||||||
|  | <dl><dt><a name="Storage-__init__"><strong>__init__</strong></a>(self, filename)</dt></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="Storage-get"><strong>get</strong></a>(self)</dt><dd><tt>Retrieve Credential from file.<br> | ||||||
|  |  <br> | ||||||
|  | Returns:<br> | ||||||
|  |   apiclient.oauth.Credentials</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="Storage-put"><strong>put</strong></a>(self, credentials)</dt><dd><tt>Write a pickled Credentials to file.<br> | ||||||
|  |  <br> | ||||||
|  | Args:<br> | ||||||
|  |   credentials: Credentials, the credentials to store.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Data descriptors inherited from <a href="apiclient.oauth.html#Storage">apiclient.oauth.Storage</a>:<br> | ||||||
|  | <dl><dt><strong>__dict__</strong></dt> | ||||||
|  | <dd><tt>dictionary for instance variables (if defined)</tt></dd> | ||||||
|  | </dl> | ||||||
|  | <dl><dt><strong>__weakref__</strong></dt> | ||||||
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | ||||||
|  | </dl> | ||||||
|  | </td></tr></table></td></tr></table><p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#55aa55"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> | ||||||
|  |      | ||||||
|  | <tr><td bgcolor="#55aa55"><tt>      </tt></td><td> </td> | ||||||
|  | <td width="100%"><strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'</td></tr></table><p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#7799ee"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> | ||||||
|  |      | ||||||
|  | <tr><td bgcolor="#7799ee"><tt>      </tt></td><td> </td> | ||||||
|  | <td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table> | ||||||
|  | </body></html> | ||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.ext</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.ext</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/__init__.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/ext/__init__.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/ext/__init__.py">/home/jcgregorio/projects/apiary/apiclient/ext/__init__.py</a></font></td></tr></table> | ||||||
|     <p></p> |     <p></p> | ||||||
| <p> | <p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| @@ -20,5 +20,6 @@ | |||||||
| <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="apiclient.ext.appengine.html">appengine</a><br> | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="apiclient.ext.appengine.html">appengine</a><br> | ||||||
| </td><td width="25%" valign=top><a href="apiclient.ext.authtools.html">authtools</a><br> | </td><td width="25%" valign=top><a href="apiclient.ext.authtools.html">authtools</a><br> | ||||||
| </td><td width="25%" valign=top><a href="apiclient.ext.django_orm.html">django_orm</a><br> | </td><td width="25%" valign=top><a href="apiclient.ext.django_orm.html">django_orm</a><br> | ||||||
| </td><td width="25%" valign=top></td></tr></table></td></tr></table> | </td><td width="25%" valign=top><a href="apiclient.ext.file.html">file</a><br> | ||||||
|  | </td></tr></table></td></tr></table> | ||||||
| </body></html> | </body></html> | ||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>apiclient</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>apiclient</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/__init__.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/__init__.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/__init__.py">/home/jcgregorio/projects/apiary/apiclient/__init__.py</a></font></td></tr></table> | ||||||
|     <p></p> |     <p></p> | ||||||
| <p> | <p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| @@ -19,12 +19,11 @@ | |||||||
| <tr><td bgcolor="#aa55cc"><tt>      </tt></td><td> </td> | <tr><td bgcolor="#aa55cc"><tt>      </tt></td><td> </td> | ||||||
| <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="apiclient.anyjson.html">anyjson</a><br> | <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="apiclient.anyjson.html">anyjson</a><br> | ||||||
| <a href="apiclient.contrib.html"><strong>contrib</strong> (package)</a><br> | <a href="apiclient.contrib.html"><strong>contrib</strong> (package)</a><br> | ||||||
| <a href="apiclient.discovery.html">discovery</a><br> | </td><td width="25%" valign=top><a href="apiclient.discovery.html">discovery</a><br> | ||||||
| </td><td width="25%" valign=top><a href="apiclient.errors.html">errors</a><br> | <a href="apiclient.errors.html">errors</a><br> | ||||||
| <a href="apiclient.ext.html"><strong>ext</strong> (package)</a><br> | </td><td width="25%" valign=top><a href="apiclient.ext.html"><strong>ext</strong> (package)</a><br> | ||||||
| <a href="apiclient.http.html">http</a><br> | <a href="apiclient.http.html">http</a><br> | ||||||
| </td><td width="25%" valign=top><a href="apiclient.json.html">json</a><br> | </td><td width="25%" valign=top><a href="apiclient.model.html">model</a><br> | ||||||
| <a href="apiclient.model.html">model</a><br> |  | ||||||
| <a href="apiclient.oauth.html">oauth</a><br> | <a href="apiclient.oauth.html">oauth</a><br> | ||||||
| </td><td width="25%" valign=top></td></tr></table></td></tr></table> | </td></tr></table></td></tr></table> | ||||||
| </body></html> | </body></html> | ||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.http</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.http</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/http.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/http.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/http.py">/home/jcgregorio/projects/apiary/apiclient/http.py</a></font></td></tr></table> | ||||||
|     <p><tt>Classes to encapsulate a single HTTP request.<br> |     <p><tt>Classes to encapsulate a single HTTP request.<br> | ||||||
|  <br> |  <br> | ||||||
| The classes implement a command pattern, with every<br> | The classes implement a command pattern, with every<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.model</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.model</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/model.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/model.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/model.py">/home/jcgregorio/projects/apiary/apiclient/model.py</a></font></td></tr></table> | ||||||
|     <p><tt><a href="#Model">Model</a> objects for requests and responses.<br> |     <p><tt><a href="#Model">Model</a> objects for requests and responses.<br> | ||||||
|  <br> |  <br> | ||||||
| Each API may support one or more serializations, such<br> | Each API may support one or more serializations, such<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.oauth</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.oauth</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/oauth.py">/usr/local/google/home/jcgregorio/projects/apiclient/apiclient/oauth.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/apiclient/oauth.py">/home/jcgregorio/projects/apiary/apiclient/oauth.py</a></font></td></tr></table> | ||||||
|     <p><tt>Utilities for OAuth.<br> |     <p><tt>Utilities for OAuth.<br> | ||||||
|  <br> |  <br> | ||||||
| Utilities for making it easier to work with OAuth.</tt></p> | Utilities for making it easier to work with OAuth.</tt></p> | ||||||
| @@ -49,7 +49,8 @@ Utilities for making it easier to work with&n | |||||||
| <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#FlowThreeLegged">FlowThreeLegged</a> | <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#FlowThreeLegged">FlowThreeLegged</a> | ||||||
| </font></dt></dl> | </font></dt></dl> | ||||||
| </dd> | </dd> | ||||||
| </dl> | <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#Storage">Storage</a> | ||||||
|  | </font></dt></dl> | ||||||
| </dd> | </dd> | ||||||
| <dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>) | <dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>) | ||||||
| </font></dt><dd> | </font></dt><dd> | ||||||
| @@ -57,7 +58,8 @@ Utilities for making it easier to work with&n | |||||||
| <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#Error">Error</a> | <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#Error">Error</a> | ||||||
| </font></dt><dd> | </font></dt><dd> | ||||||
| <dl> | <dl> | ||||||
| <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#MissingParameter">MissingParameter</a> | <dt><font face="helvetica, arial"><a href="apiclient.oauth.html#CredentialsInvalidError">CredentialsInvalidError</a> | ||||||
|  | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.oauth.html#MissingParameter">MissingParameter</a> | ||||||
| </font></dt><dt><font face="helvetica, arial"><a href="apiclient.oauth.html#RequestError">RequestError</a> | </font></dt><dt><font face="helvetica, arial"><a href="apiclient.oauth.html#RequestError">RequestError</a> | ||||||
| </font></dt></dl> | </font></dt></dl> | ||||||
| </dd> | </dd> | ||||||
| @@ -95,6 +97,65 @@ Data descriptors defined here:<br> | |||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| <tr bgcolor="#ffc8d8"> | <tr bgcolor="#ffc8d8"> | ||||||
| <td colspan=3 valign=bottom> <br> | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#000000" face="helvetica, arial"><a name="CredentialsInvalidError">class <strong>CredentialsInvalidError</strong></a>(<a href="apiclient.oauth.html#Error">Error</a>)</font></td></tr> | ||||||
|  |      | ||||||
|  | <tr><td bgcolor="#ffc8d8"><tt>   </tt></td><td> </td> | ||||||
|  | <td width="100%"><dl><dt>Method resolution order:</dt> | ||||||
|  | <dd><a href="apiclient.oauth.html#CredentialsInvalidError">CredentialsInvalidError</a></dd> | ||||||
|  | <dd><a href="apiclient.oauth.html#Error">Error</a></dd> | ||||||
|  | <dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd> | ||||||
|  | <dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd> | ||||||
|  | <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> | ||||||
|  | </dl> | ||||||
|  | <hr> | ||||||
|  | Data descriptors inherited from <a href="apiclient.oauth.html#Error">Error</a>:<br> | ||||||
|  | <dl><dt><strong>__weakref__</strong></dt> | ||||||
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | ||||||
|  | </dl> | ||||||
|  | <hr> | ||||||
|  | Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__init__">__init__</a>(...) initializes x; see x.__class__.__doc__ for signature</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br> | ||||||
|  | <dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#CredentialsInvalidError-__new__">__new__</a>(S, ...) -> a new <a href="__builtin__.html#object">object</a> with type S, a subtype of T</tt></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br> | ||||||
|  |  <br> | ||||||
|  | Use of negative indices is not supported.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#CredentialsInvalidError-__str__">__str__</a>() <==> str(x)</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="CredentialsInvalidError-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br> | ||||||
|  | <dl><dt><strong>__dict__</strong></dt> | ||||||
|  | </dl> | ||||||
|  | <dl><dt><strong>args</strong></dt> | ||||||
|  | </dl> | ||||||
|  | <dl><dt><strong>message</strong></dt> | ||||||
|  | </dl> | ||||||
|  | </td></tr></table> <p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#ffc8d8"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
| <font color="#000000" face="helvetica, arial"><a name="Error">class <strong>Error</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr> | <font color="#000000" face="helvetica, arial"><a name="Error">class <strong>Error</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr> | ||||||
|      |      | ||||||
| <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | ||||||
| @@ -292,11 +353,15 @@ Data descriptors inherited from <a href="exceptions.html#BaseException">exceptio | |||||||
| </dl> | </dl> | ||||||
| <hr> | <hr> | ||||||
| Methods defined here:<br> | Methods defined here:<br> | ||||||
|  | <dl><dt><a name="OAuthCredentials-__getstate__"><strong>__getstate__</strong></a>(self)</dt><dd><tt>Trim the state down to something that can be pickled.</tt></dd></dl> | ||||||
|  |  | ||||||
| <dl><dt><a name="OAuthCredentials-__init__"><strong>__init__</strong></a>(self, consumer, token, user_agent)</dt><dd><tt>consumer   - An instance of oauth.Consumer.<br> | <dl><dt><a name="OAuthCredentials-__init__"><strong>__init__</strong></a>(self, consumer, token, user_agent)</dt><dd><tt>consumer   - An instance of oauth.Consumer.<br> | ||||||
| token      - An instance of oauth.Token constructed with<br> | token      - An instance of oauth.Token constructed with<br> | ||||||
|              the access token and secret.<br> |              the access token and secret.<br> | ||||||
| user_agent - The HTTP User-Agent to provide for this application.</tt></dd></dl> | user_agent - The HTTP User-Agent to provide for this application.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="OAuthCredentials-__setstate__"><strong>__setstate__</strong></a>(self, state)</dt><dd><tt>Reconstitute the state of the <a href="__builtin__.html#object">object</a> from being pickled.</tt></dd></dl> | ||||||
|  |  | ||||||
| <dl><dt><a name="OAuthCredentials-authorize"><strong>authorize</strong></a>(self, http)</dt><dd><tt>Args:<br> | <dl><dt><a name="OAuthCredentials-authorize"><strong>authorize</strong></a>(self, http)</dt><dd><tt>Args:<br> | ||||||
|    http - An instance of httplib2.Http<br> |    http - An instance of httplib2.Http<br> | ||||||
|        or something that acts like it.<br> |        or something that acts like it.<br> | ||||||
| @@ -317,6 +382,19 @@ needed for signing. So instead we have to&nbs | |||||||
| Authorization header and then calls the original version<br> | Authorization header and then calls the original version<br> | ||||||
| of 'request()'.</tt></dd></dl> | of 'request()'.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="OAuthCredentials-set_store"><strong>set_store</strong></a>(self, store)</dt><dd><tt>Set the storage for the credential.<br> | ||||||
|  |  <br> | ||||||
|  | Args:<br> | ||||||
|  |   store: callable, a callable that when passed a Credential<br> | ||||||
|  |     will store the credential back to where it came from.<br> | ||||||
|  |     This is needed to store the latest access_token if it<br> | ||||||
|  |     has been revoked.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Data descriptors defined here:<br> | ||||||
|  | <dl><dt><strong>invalid</strong></dt> | ||||||
|  | <dd><tt>True if the credentials are invalid, such as being revoked.</tt></dd> | ||||||
|  | </dl> | ||||||
| <hr> | <hr> | ||||||
| Data descriptors inherited from <a href="apiclient.oauth.html#Credentials">Credentials</a>:<br> | Data descriptors inherited from <a href="apiclient.oauth.html#Credentials">Credentials</a>:<br> | ||||||
| <dl><dt><strong>__dict__</strong></dt> | <dl><dt><strong>__dict__</strong></dt> | ||||||
| @@ -386,6 +464,36 @@ Data descriptors inherited from <a href="exceptions.html#BaseException">exceptio | |||||||
| </dl> | </dl> | ||||||
| <dl><dt><strong>message</strong></dt> | <dl><dt><strong>message</strong></dt> | ||||||
| </dl> | </dl> | ||||||
|  | </td></tr></table> <p> | ||||||
|  | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|  | <tr bgcolor="#ffc8d8"> | ||||||
|  | <td colspan=3 valign=bottom> <br> | ||||||
|  | <font color="#000000" face="helvetica, arial"><a name="Storage">class <strong>Storage</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> | ||||||
|  |      | ||||||
|  | <tr bgcolor="#ffc8d8"><td rowspan=2><tt>   </tt></td> | ||||||
|  | <td colspan=2><tt>Base class for all <a href="#Storage">Storage</a> objects.<br> | ||||||
|  |  <br> | ||||||
|  | Store and retrieve a single credential.<br> </tt></td></tr> | ||||||
|  | <tr><td> </td> | ||||||
|  | <td width="100%">Methods defined here:<br> | ||||||
|  | <dl><dt><a name="Storage-get"><strong>get</strong></a>(self)</dt><dd><tt>Retrieve credential.<br> | ||||||
|  |  <br> | ||||||
|  | Returns:<br> | ||||||
|  |   apiclient.oauth.<a href="#Credentials">Credentials</a></tt></dd></dl> | ||||||
|  |  | ||||||
|  | <dl><dt><a name="Storage-put"><strong>put</strong></a>(self, credentials)</dt><dd><tt>Write a credential.<br> | ||||||
|  |  <br> | ||||||
|  | Args:<br> | ||||||
|  |   credentials: <a href="#Credentials">Credentials</a>, the credentials to store.</tt></dd></dl> | ||||||
|  |  | ||||||
|  | <hr> | ||||||
|  | Data descriptors defined here:<br> | ||||||
|  | <dl><dt><strong>__dict__</strong></dt> | ||||||
|  | <dd><tt>dictionary for instance variables (if defined)</tt></dd> | ||||||
|  | </dl> | ||||||
|  | <dl><dt><strong>__weakref__</strong></dt> | ||||||
|  | <dd><tt>list of weak references to the object (if defined)</tt></dd> | ||||||
|  | </dl> | ||||||
| </td></tr></table></td></tr></table><p> | </td></tr></table></td></tr></table><p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| <tr bgcolor="#55aa55"> | <tr bgcolor="#55aa55"> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.appengine</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.appengine</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/appengine.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/appengine.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/appengine.py">/home/jcgregorio/projects/apiary/oauth2client/appengine.py</a></font></td></tr></table> | ||||||
|     <p><tt>Utilities for Google App Engine<br> |     <p><tt>Utilities for Google App Engine<br> | ||||||
|  <br> |  <br> | ||||||
| Utilities for making it easier to use OAuth 2.0 on Google App Engine.</tt></p> | Utilities for making it easier to use OAuth 2.0 on Google App Engine.</tt></p> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.client</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.client</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/client.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/client.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/client.py">/home/jcgregorio/projects/apiary/oauth2client/client.py</a></font></td></tr></table> | ||||||
|     <p><tt>An OAuth 2.0 client<br> |     <p><tt>An OAuth 2.0 client<br> | ||||||
|  <br> |  <br> | ||||||
| Tools for interacting with OAuth 2.0 protected<br> | Tools for interacting with OAuth 2.0 protected<br> | ||||||
| @@ -88,7 +88,7 @@ client or another web application, and wish t | |||||||
| only the access_token is present it can not be refreshed and will in time<br> | only the access_token is present it can not be refreshed and will in time<br> | ||||||
| expire.<br> | expire.<br> | ||||||
|  <br> |  <br> | ||||||
| <a href="#OAuth2Credentials">OAuth2Credentials</a> objects may be safely pickled and unpickled.<br> | <a href="#AccessTokenCredentials">AccessTokenCredentials</a> objects may be safely pickled and unpickled.<br> | ||||||
|  <br> |  <br> | ||||||
| Usage:<br> | Usage:<br> | ||||||
|   credentials = <a href="#AccessTokenCredentials">AccessTokenCredentials</a>('<an access token>',<br> |   credentials = <a href="#AccessTokenCredentials">AccessTokenCredentials</a>('<an access token>',<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.django_orm</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.django_orm</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/django_orm.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/django_orm.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/django_orm.py">/home/jcgregorio/projects/apiary/oauth2client/django_orm.py</a></font></td></tr></table> | ||||||
|     <p><tt>OAuth 2.0 utilities for Django.<br> |     <p><tt>OAuth 2.0 utilities for Django.<br> | ||||||
|  <br> |  <br> | ||||||
| Utilities for using OAuth 2.0 in conjunction with<br> | Utilities for using OAuth 2.0 in conjunction with<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.file</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.file</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/file.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/file.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/file.py">/home/jcgregorio/projects/apiary/oauth2client/file.py</a></font></td></tr></table> | ||||||
|     <p><tt>Utilities for OAuth.<br> |     <p><tt>Utilities for OAuth.<br> | ||||||
|  <br> |  <br> | ||||||
| Utilities for making it easier to work with OAuth 2.0<br> | Utilities for making it easier to work with OAuth 2.0<br> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>oauth2client</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>oauth2client</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/__init__.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/__init__.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/__init__.py">/home/jcgregorio/projects/apiary/oauth2client/__init__.py</a></font></td></tr></table> | ||||||
|     <p></p> |     <p></p> | ||||||
| <p> | <p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| <td valign=bottom> <br> | <td valign=bottom> <br> | ||||||
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.tools</strong></big></big></font></td | <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.tools</strong></big></big></font></td | ||||||
| ><td align=right valign=bottom | ><td align=right valign=bottom | ||||||
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/tools.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/tools.py</a></font></td></tr></table> | ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/apiary/oauth2client/tools.py">/home/jcgregorio/projects/apiary/oauth2client/tools.py</a></font></td></tr></table> | ||||||
|     <p><tt>Command-line tools for authenticating via OAuth 2.0<br> |     <p><tt>Command-line tools for authenticating via OAuth 2.0<br> | ||||||
|  <br> |  <br> | ||||||
| Do the OAuth 2.0 Web Server dance for a command line application. Stores the<br> | Do the OAuth 2.0 Web Server dance for a command line application. Stores the<br> | ||||||
| @@ -21,7 +21,17 @@ the same directory.</tt></p> | |||||||
| <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> | ||||||
|      |      | ||||||
| <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | <tr><td bgcolor="#eeaa77"><tt>      </tt></td><td> </td> | ||||||
| <td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(flow, storage)</dt><dd><tt>Core code for a command-line application.</tt></dd></dl> | <td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(flow, storage)</dt><dd><tt>Core code for a command-line application.<br> | ||||||
|  |  <br> | ||||||
|  | Args:<br> | ||||||
|  |   flow: Flow, an OAuth 2.0 Flow to step through.<br> | ||||||
|  |   storage: Storage, a Storage to store the credential in.<br> | ||||||
|  |  <br> | ||||||
|  | Returns:<br> | ||||||
|  |   Credentials, the obtained credential.<br> | ||||||
|  |  <br> | ||||||
|  | Exceptions:<br> | ||||||
|  |   RequestError: if step2 of the flow fails.</tt></dd></dl> | ||||||
| </td></tr></table><p> | </td></tr></table><p> | ||||||
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | ||||||
| <tr bgcolor="#55aa55"> | <tr bgcolor="#55aa55"> | ||||||
|   | |||||||
| @@ -25,6 +25,16 @@ __all__ = ['run'] | |||||||
|  |  | ||||||
| def run(flow, storage): | def run(flow, storage): | ||||||
|   """Core code for a command-line application. |   """Core code for a command-line application. | ||||||
|  |  | ||||||
|  |   Args: | ||||||
|  |     flow: Flow, an OAuth 2.0 Flow to step through. | ||||||
|  |     storage: Storage, a Storage to store the credential in. | ||||||
|  |  | ||||||
|  |   Returns: | ||||||
|  |     Credentials, the obtained credential. | ||||||
|  |  | ||||||
|  |   Exceptions: | ||||||
|  |     RequestError: if step2 of the flow fails. | ||||||
|   """ |   """ | ||||||
|   authorize_url = flow.step1_get_authorize_url('oob') |   authorize_url = flow.step1_get_authorize_url('oob') | ||||||
|  |  | ||||||
| @@ -37,7 +47,10 @@ def run(flow, storage): | |||||||
|     accepted = raw_input('Have you authorized me? (y/n) ') |     accepted = raw_input('Have you authorized me? (y/n) ') | ||||||
|   code = raw_input('What is the verification code? ').strip() |   code = raw_input('What is the verification code? ').strip() | ||||||
|  |  | ||||||
|   credentials = flow.step2_exchange(code) |   try: | ||||||
|  |     credentials = flow.step2_exchange(code) | ||||||
|  |   except RequestError: | ||||||
|  |     sys.exit('The authentication has failed.') | ||||||
|  |  | ||||||
|   storage.put(credentials) |   storage.put(credentials) | ||||||
|   credentials.set_store(storage.put) |   credentials.set_store(storage.put) | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ from apiclient.ext.file import Storage | |||||||
| from apiclient.oauth import CredentialsInvalidError | from apiclient.oauth import CredentialsInvalidError | ||||||
|  |  | ||||||
| import httplib2 | import httplib2 | ||||||
| import pickle |  | ||||||
| import pprint | import pprint | ||||||
|  |  | ||||||
| # Uncomment the next line to get very detailed logging | # Uncomment the next line to get very detailed logging | ||||||
| @@ -26,7 +25,8 @@ import pprint | |||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   credentials = Storage('buzz.dat').get() |   storage = Storage('buzz.dat') | ||||||
|  |   credentials = storage.get() | ||||||
|   if credentials is None or credentials.invalid == True: |   if credentials is None or credentials.invalid == True: | ||||||
|     buzz_discovery = build("buzz", "v1").auth_discovery() |     buzz_discovery = build("buzz", "v1").auth_discovery() | ||||||
|  |  | ||||||
| @@ -38,7 +38,7 @@ def main(): | |||||||
|                            scope='https://www.googleapis.com/auth/buzz', |                            scope='https://www.googleapis.com/auth/buzz', | ||||||
|                            xoauth_displayname='Google API Client Example App') |                            xoauth_displayname='Google API Client Example App') | ||||||
|  |  | ||||||
|     credentials = run(flow, 'buzz.dat') |     credentials = run(flow, storage) | ||||||
|  |  | ||||||
|   http = httplib2.Http() |   http = httplib2.Http() | ||||||
|   http = credentials.authorize(http) |   http = credentials.authorize(http) | ||||||
|   | |||||||
| @@ -27,7 +27,8 @@ from apiclient.ext.file import Storage | |||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   credentials = Storage('latitude.dat').get() |   storage = Storage('latitude.dat') | ||||||
|  |   credentials = storage.get() | ||||||
|   if credentials is None or credentials.invalid == True: |   if credentials is None or credentials.invalid == True: | ||||||
|     auth_discovery = build("latitude", "v1").auth_discovery() |     auth_discovery = build("latitude", "v1").auth_discovery() | ||||||
|     flow = FlowThreeLegged(auth_discovery, |     flow = FlowThreeLegged(auth_discovery, | ||||||
| @@ -45,7 +46,7 @@ def main(): | |||||||
|                            granularity='city' |                            granularity='city' | ||||||
|                            ) |                            ) | ||||||
|  |  | ||||||
|     credentials = run(flow, 'latitude.dat') |     credentials = run(flow, storage) | ||||||
|  |  | ||||||
|   http = httplib2.Http() |   http = httplib2.Http() | ||||||
|   http = credentials.authorize(http) |   http = credentials.authorize(http) | ||||||
|   | |||||||
| @@ -11,10 +11,14 @@ latest content and then adds a new entry. | |||||||
|  |  | ||||||
| __author__ = 'jcgregorio@google.com (Joe Gregorio)' | __author__ = 'jcgregorio@google.com (Joe Gregorio)' | ||||||
|  |  | ||||||
|  | from apiclient.discovery import build | ||||||
| from apiclient.discovery import build_from_document | from apiclient.discovery import build_from_document | ||||||
|  | from apiclient.oauth import FlowThreeLegged | ||||||
|  | from apiclient.ext.authtools import run | ||||||
|  | from apiclient.ext.file import Storage | ||||||
|  | from apiclient.oauth import CredentialsInvalidError | ||||||
|  |  | ||||||
| import httplib2 | import httplib2 | ||||||
| import pickle |  | ||||||
| import pprint | import pprint | ||||||
|  |  | ||||||
| # Uncomment the next line to get very detailed logging | # Uncomment the next line to get very detailed logging | ||||||
| @@ -22,10 +26,20 @@ import pprint | |||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   # Load the credentials and authorize |   storage = Storage('buzz.dat') | ||||||
|   f = open("buzz.dat", "r") |   credentials = storage.get() | ||||||
|   credentials = pickle.loads(f.read()) |   if credentials is None or credentials.invalid == True: | ||||||
|   f.close() |     buzz_discovery = build("buzz", "v1").auth_discovery() | ||||||
|  |  | ||||||
|  |     flow = FlowThreeLegged(buzz_discovery, | ||||||
|  |                            consumer_key='anonymous', | ||||||
|  |                            consumer_secret='anonymous', | ||||||
|  |                            user_agent='python-buzz-sample/1.0', | ||||||
|  |                            domain='anonymous', | ||||||
|  |                            scope='https://www.googleapis.com/auth/buzz', | ||||||
|  |                            xoauth_displayname='Google API Client Example App') | ||||||
|  |  | ||||||
|  |     credentials = run(flow, storage) | ||||||
|  |  | ||||||
|   http = httplib2.Http() |   http = httplib2.Http() | ||||||
|   http = credentials.authorize(http) |   http = credentials.authorize(http) | ||||||
| @@ -48,43 +62,15 @@ def main(): | |||||||
|       developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0") |       developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0") | ||||||
|   activities = p.activities() |   activities = p.activities() | ||||||
|  |  | ||||||
|   # Retrieve the first two activities |   try: | ||||||
|   activitylist = activities.list( |     # Retrieve the first two activities | ||||||
|       max_results='2', scope='@self', userId='@me').execute() |     activitylist = activities.list( | ||||||
|   print "Retrieved the first two activities" |         max_results='2', scope='@self', userId='@me').execute() | ||||||
|  |     print "Retrieved the first two activities" | ||||||
|  |   except CredentialsInvalidError: | ||||||
|  |     print 'Your credentials are no longer valid.' | ||||||
|  |     print 'Please re-run this application to re-authorize.' | ||||||
|  |  | ||||||
|   # Retrieve the next two activities |  | ||||||
|   if activitylist: |  | ||||||
|     activitylist = activities.list_next(activitylist).execute() |  | ||||||
|     print "Retrieved the next two activities" |  | ||||||
|  |  | ||||||
|   # Add a new activity |  | ||||||
|   new_activity_body = { |  | ||||||
|       "data": { |  | ||||||
|         'title': 'Testing insert', |  | ||||||
|         'object': { |  | ||||||
|           'content': u'Just a short note to show that insert is working. ☄', |  | ||||||
|           'type': 'note'} |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|   activity = activities.insert(userId='@me', body=new_activity_body).execute() |  | ||||||
|   print "Added a new activity" |  | ||||||
|  |  | ||||||
|   activitylist = activities.list( |  | ||||||
|       max_results='2', scope='@self', userId='@me').execute() |  | ||||||
|  |  | ||||||
|   # Add a comment to that activity |  | ||||||
|   comment_body = { |  | ||||||
|       "data": { |  | ||||||
|           "content": "This is a comment" |  | ||||||
|           } |  | ||||||
|       } |  | ||||||
|   item = activitylist['items'][0] |  | ||||||
|   comment = p.comments().insert( |  | ||||||
|       userId=item['actor']['id'], postId=item['id'], body=comment_body |  | ||||||
|       ).execute() |  | ||||||
|   print 'Added a comment to the new activity' |  | ||||||
|   pprint.pprint(comment) |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   main() |   main() | ||||||
|   | |||||||
| @@ -1,40 +0,0 @@ | |||||||
| # Copyright (C) 2010 Google Inc. |  | ||||||
| # |  | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| # you may not use this file except in compliance with the License. |  | ||||||
| # You may obtain a copy of the License at |  | ||||||
| # |  | ||||||
| #      http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
| # |  | ||||||
| # Unless required by applicable law or agreed to in writing, software |  | ||||||
| # distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| # See the License for the specific language governing permissions and |  | ||||||
| # limitations under the License. |  | ||||||
|  |  | ||||||
| """Do the OAuth 1.0a three legged dance. |  | ||||||
|  |  | ||||||
| Do the OAuth 1.0a three legged dance for |  | ||||||
| a Buzz command line application. Store the generated |  | ||||||
| credentials in a common file that is used by |  | ||||||
| other example apps in the same directory. |  | ||||||
| """ |  | ||||||
|  |  | ||||||
| __author__ = 'jcgregorio@google.com (Joe Gregorio)' |  | ||||||
|  |  | ||||||
| from apiclient.discovery import build |  | ||||||
| from apiclient.oauth import FlowThreeLegged |  | ||||||
| from apiclient.ext.authtools import run |  | ||||||
|  |  | ||||||
|  |  | ||||||
| buzz_discovery = build("buzz", "v1").auth_discovery() |  | ||||||
|  |  | ||||||
| flow = FlowThreeLegged(buzz_discovery, |  | ||||||
|                        consumer_key='anonymous', |  | ||||||
|                        consumer_secret='anonymous', |  | ||||||
|                        user_agent='google-api-client-python-buzz-cmdline/1.0', |  | ||||||
|                        domain='anonymous', |  | ||||||
|                        scope='https://www.googleapis.com/auth/buzz', |  | ||||||
|                        xoauth_displayname='Google API Client Example App') |  | ||||||
|  |  | ||||||
| run(flow, 'buzz.dat') |  | ||||||
| @@ -13,18 +13,33 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)' | |||||||
|  |  | ||||||
|  |  | ||||||
| from apiclient.discovery import build | from apiclient.discovery import build | ||||||
|  | from apiclient.oauth import FlowThreeLegged | ||||||
|  | from apiclient.ext.authtools import run | ||||||
|  | from apiclient.ext.file import Storage | ||||||
|  | from apiclient.oauth import CredentialsInvalidError | ||||||
|  |  | ||||||
| import httplib2 | import httplib2 | ||||||
| import pickle |  | ||||||
|  |  | ||||||
| # Uncomment to get detailed logging | # Uncomment to get detailed logging | ||||||
| # httplib2.debuglevel = 4 | # httplib2.debuglevel = 4 | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   f = open("moderator.dat", "r") |   storage = Storage('moderator.dat') | ||||||
|   credentials = pickle.loads(f.read()) |   credentials = storage.get() | ||||||
|   f.close() |   if credentials is None or credentials.invalid == True: | ||||||
|  |     moderator_discovery = build("moderator", "v1").auth_discovery() | ||||||
|  |  | ||||||
|  |     flow = FlowThreeLegged(moderator_discovery, | ||||||
|  |                            consumer_key='anonymous', | ||||||
|  |                            consumer_secret='anonymous', | ||||||
|  |                            user_agent='google-api-client-python-mdrtr-cmdline/1.0', | ||||||
|  |                            domain='anonymous', | ||||||
|  |                            scope='https://www.googleapis.com/auth/moderator', | ||||||
|  |                            #scope='tag:google.com,2010:auth/moderator', | ||||||
|  |                            xoauth_displayname='Google API Client Example App') | ||||||
|  |  | ||||||
|  |     credentials = run(flow, storage) | ||||||
|  |  | ||||||
|   http = httplib2.Http() |   http = httplib2.Http() | ||||||
|   http = credentials.authorize(http) |   http = credentials.authorize(http) | ||||||
| @@ -38,43 +53,47 @@ def main(): | |||||||
|         "videoSubmissionAllowed": False |         "videoSubmissionAllowed": False | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|   series = p.series().insert(body=series_body).execute() |   try: | ||||||
|   print "Created a new series" |     series = p.series().insert(body=series_body).execute() | ||||||
|  |     print "Created a new series" | ||||||
|  |  | ||||||
|   topic_body = { |     topic_body = { | ||||||
|       "data": { |         "data": { | ||||||
|         "description": "Share your ideas on eating healthy!", |           "description": "Share your ideas on eating healthy!", | ||||||
|         "name": "Ideas", |           "name": "Ideas", | ||||||
|         "presenter": "liz" |           "presenter": "liz" | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |     topic = p.topics().insert(seriesId=series['id']['seriesId'], | ||||||
|   topic = p.topics().insert(seriesId=series['id']['seriesId'], |                               body=topic_body).execute() | ||||||
|                             body=topic_body).execute() |     print "Created a new topic" | ||||||
|   print "Created a new topic" |  | ||||||
|  |  | ||||||
|   submission_body = { |     submission_body = { | ||||||
|       "data": { |         "data": { | ||||||
|         "attachmentUrl": "http://www.youtube.com/watch?v=1a1wyc5Xxpg", |           "attachmentUrl": "http://www.youtube.com/watch?v=1a1wyc5Xxpg", | ||||||
|         "attribution": { |           "attribution": { | ||||||
|           "displayName": "Bashan", |             "displayName": "Bashan", | ||||||
|           "location": "Bainbridge Island, WA" |             "location": "Bainbridge Island, WA" | ||||||
|           }, |             }, | ||||||
|         "text": "Charlie Ayers @ Google" |           "text": "Charlie Ayers @ Google" | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |     submission = p.submissions().insert(seriesId=topic['id']['seriesId'], | ||||||
|   submission = p.submissions().insert(seriesId=topic['id']['seriesId'], |         topicId=topic['id']['topicId'], body=submission_body).execute() | ||||||
|       topicId=topic['id']['topicId'], body=submission_body).execute() |     print "Inserted a new submisson on the topic" | ||||||
|   print "Inserted a new submisson on the topic" |  | ||||||
|  |  | ||||||
|   vote_body = { |     vote_body = { | ||||||
|       "data": { |         "data": { | ||||||
|         "vote": "PLUS" |           "vote": "PLUS" | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |     p.votes().insert(seriesId=topic['id']['seriesId'], | ||||||
|   p.votes().insert(seriesId=topic['id']['seriesId'], |                      submissionId=submission['id']['submissionId'], | ||||||
|                    submissionId=submission['id']['submissionId'], |                      body=vote_body) | ||||||
|                    body=vote_body) |     print "Voted on the submission" | ||||||
|   print "Voted on the submission" |   except CredentialsInvalidError: | ||||||
|  |     print 'Your credentials are no longer valid.' | ||||||
|  |     print 'Please re-run this application to re-authorize.' | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   | |||||||
| @@ -1,41 +0,0 @@ | |||||||
| # Copyright (C) 2010 Google Inc. |  | ||||||
| # |  | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| # you may not use this file except in compliance with the License. |  | ||||||
| # You may obtain a copy of the License at |  | ||||||
| # |  | ||||||
| #      http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
| # |  | ||||||
| # Unless required by applicable law or agreed to in writing, software |  | ||||||
| # distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| # See the License for the specific language governing permissions and |  | ||||||
| # limitations under the License. |  | ||||||
|  |  | ||||||
| """Do the OAuth 1.0a three legged dance. |  | ||||||
|  |  | ||||||
| Do the OAuth 1.0a three legged dance for |  | ||||||
| a Buzz command line application. Store the generated |  | ||||||
| credentials in a common file that is used by |  | ||||||
| other example apps in the same directory. |  | ||||||
| """ |  | ||||||
|  |  | ||||||
| __author__ = 'jcgregorio@google.com (Joe Gregorio)' |  | ||||||
|  |  | ||||||
| from apiclient.discovery import build |  | ||||||
| from apiclient.oauth import FlowThreeLegged |  | ||||||
| from apiclient.ext.authtools import run |  | ||||||
|  |  | ||||||
|  |  | ||||||
| moderator_discovery = build("moderator", "v1").auth_discovery() |  | ||||||
|  |  | ||||||
| flow = FlowThreeLegged(moderator_discovery, |  | ||||||
|                        consumer_key='anonymous', |  | ||||||
|                        consumer_secret='anonymous', |  | ||||||
|                        user_agent='google-api-client-python-mdrtr-cmdline/1.0', |  | ||||||
|                        domain='anonymous', |  | ||||||
|                        scope='https://www.googleapis.com/auth/moderator', |  | ||||||
|                        #scope='tag:google.com,2010:auth/moderator', |  | ||||||
|                        xoauth_displayname='Google API Client Example App') |  | ||||||
|  |  | ||||||
| run(flow, 'moderator.dat') |  | ||||||
| @@ -1,9 +1,13 @@ | |||||||
| from apiclient.discovery import build | from apiclient.discovery import build | ||||||
| from apiclient.discovery import HttpError | from apiclient.discovery import build | ||||||
|  | from apiclient.errors import HttpError | ||||||
|  | from apiclient.ext.authtools import run | ||||||
|  | from apiclient.ext.file import Storage | ||||||
|  | from apiclient.oauth import CredentialsInvalidError | ||||||
|  | from apiclient.oauth import FlowThreeLegged | ||||||
|  |  | ||||||
| import Queue | import Queue | ||||||
| import httplib2 | import httplib2 | ||||||
| import pickle |  | ||||||
| import threading | import threading | ||||||
| import time | import time | ||||||
|  |  | ||||||
| @@ -47,8 +51,9 @@ def start_threads(credentials): | |||||||
|   def process_requests(): |   def process_requests(): | ||||||
|     http = httplib2.Http() |     http = httplib2.Http() | ||||||
|     http = credentials.authorize(http) |     http = credentials.authorize(http) | ||||||
|  |     credentials_ok = True | ||||||
|  |  | ||||||
|     while True: |     while credentials_ok: | ||||||
|       request = queue.get() |       request = queue.get() | ||||||
|       backoff = Backoff() |       backoff = Backoff() | ||||||
|       while backoff.loop(): |       while backoff.loop(): | ||||||
| @@ -59,10 +64,15 @@ def start_threads(credentials): | |||||||
|           if e.resp.status in [402, 403, 408, 503, 504]: |           if e.resp.status in [402, 403, 408, 503, 504]: | ||||||
|             print "Increasing backoff, got status code: %d" % e.resp.status |             print "Increasing backoff, got status code: %d" % e.resp.status | ||||||
|             backoff.fail() |             backoff.fail() | ||||||
|  |         except CredentialsInvalidError: | ||||||
|  |           print "Credentials no long valid. Exiting." | ||||||
|  |           credentials_ok = False | ||||||
|  |           break | ||||||
|  |  | ||||||
|       print "Completed request" |       print "Completed request" | ||||||
|       queue.task_done() |       queue.task_done() | ||||||
|  |  | ||||||
|  |  | ||||||
|   for i in range(NUM_THREADS): |   for i in range(NUM_THREADS): | ||||||
|     t = threading.Thread(target=process_requests) |     t = threading.Thread(target=process_requests) | ||||||
|     t.daemon = True |     t.daemon = True | ||||||
| @@ -70,9 +80,20 @@ def start_threads(credentials): | |||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   f = open("moderator.dat", "r") |   storage = Storage('moderator.dat') | ||||||
|   credentials = pickle.loads(f.read()) |   credentials = storage.get() | ||||||
|   f.close() |   if credentials is None or credentials.invalid == True: | ||||||
|  |     moderator_discovery = build("moderator", "v1").auth_discovery() | ||||||
|  |  | ||||||
|  |     flow = FlowThreeLegged(moderator_discovery, | ||||||
|  |                            consumer_key='anonymous', | ||||||
|  |                            consumer_secret='anonymous', | ||||||
|  |                            user_agent='google-api-client-python-thread-sample/1.0', | ||||||
|  |                            domain='anonymous', | ||||||
|  |                            scope='https://www.googleapis.com/auth/moderator', | ||||||
|  |                            xoauth_displayname='Google API Client Example App') | ||||||
|  |  | ||||||
|  |     credentials = run(flow, storage) | ||||||
|  |  | ||||||
|   start_threads(credentials) |   start_threads(credentials) | ||||||
|  |  | ||||||
| @@ -88,21 +109,26 @@ def main(): | |||||||
|           "videoSubmissionAllowed": False |           "videoSubmissionAllowed": False | ||||||
|           } |           } | ||||||
|       } |       } | ||||||
|   series = p.series().insert(body=series_body).execute() |   try: | ||||||
|   print "Created a new series" |     series = p.series().insert(body=series_body).execute() | ||||||
|  |     print "Created a new series" | ||||||
|  |  | ||||||
|   for i in range(NUM_ITEMS): |     for i in range(NUM_ITEMS): | ||||||
|     topic_body = { |       topic_body = { | ||||||
|         "data": { |           "data": { | ||||||
|           "description": "Sample Topic # %d" % i, |             "description": "Sample Topic # %d" % i, | ||||||
|           "name": "Sample", |             "name": "Sample", | ||||||
|           "presenter": "me" |             "presenter": "me" | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         } |       topic_request = p.topics().insert(seriesId=series['id']['seriesId'], | ||||||
|     topic_request = p.topics().insert(seriesId=series['id']['seriesId'], |                                         body=topic_body) | ||||||
|                                       body=topic_body) |       print "Adding request to queue" | ||||||
|     print "Adding request to queue" |       queue.put(topic_request) | ||||||
|     queue.put(topic_request) |   except CredentialsInvalidError: | ||||||
|  |     print 'Your credentials are no longer valid.' | ||||||
|  |     print 'Please re-run this application to re-authorize.' | ||||||
|  |  | ||||||
|  |  | ||||||
|   queue.join() |   queue.join() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,41 +0,0 @@ | |||||||
| # Copyright (C) 2010 Google Inc. |  | ||||||
| # |  | ||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| # you may not use this file except in compliance with the License. |  | ||||||
| # You may obtain a copy of the License at |  | ||||||
| # |  | ||||||
| #      http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
| # |  | ||||||
| # Unless required by applicable law or agreed to in writing, software |  | ||||||
| # distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| # See the License for the specific language governing permissions and |  | ||||||
| # limitations under the License. |  | ||||||
|  |  | ||||||
| """Do the OAuth 1.0a three legged dance. |  | ||||||
|  |  | ||||||
| Do the OAuth 1.0a three legged dance for |  | ||||||
| a Buzz command line application. Store the generated |  | ||||||
| credentials in a common file that is used by |  | ||||||
| other example apps in the same directory. |  | ||||||
| """ |  | ||||||
|  |  | ||||||
| __author__ = 'jcgregorio@google.com (Joe Gregorio)' |  | ||||||
|  |  | ||||||
| from apiclient.discovery import build |  | ||||||
| from apiclient.oauth import FlowThreeLegged |  | ||||||
| from apiclient.ext.authtools import run |  | ||||||
|  |  | ||||||
|  |  | ||||||
| moderator_discovery = build("moderator", "v1").auth_discovery() |  | ||||||
|  |  | ||||||
| flow = FlowThreeLegged(moderator_discovery, |  | ||||||
|                        consumer_key='anonymous', |  | ||||||
|                        consumer_secret='anonymous', |  | ||||||
|                        user_agent='google-api-client-python-thread-sample/1.0', |  | ||||||
|                        domain='anonymous', |  | ||||||
|                        scope='https://www.googleapis.com/auth/moderator', |  | ||||||
|                        #scope='tag:google.com,2010:auth/moderator', |  | ||||||
|                        xoauth_displayname='Google API Client Example App') |  | ||||||
|  |  | ||||||
| run(flow, 'moderator.dat') |  | ||||||
		Reference in New Issue
	
	Block a user
	 Joe Gregorio
					Joe Gregorio