blob: 80abe9e11a6827400aa23704bd095585fa8bedab [file] [log] [blame]
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -04001<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5<head>
6 <title>oauth2client.client.AccessTokenCredentials</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>&nbsp;&nbsp;&nbsp;<a
20 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
21
22 <!-- Index link -->
23 <th>&nbsp;&nbsp;&nbsp;<a
24 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
25
26 <!-- Help link -->
27 <th>&nbsp;&nbsp;&nbsp;<a
28 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
29
30 <th class="navbar" width="100%"></th>
31 </tr>
32</table>
33<table width="100%" cellpadding="0" cellspacing="0">
34 <tr valign="top">
35 <td width="100%">
36 <span class="breadcrumbs">
37 <a href="oauth2client-module.html">Package&nbsp;oauth2client</a> ::
38 <a href="oauth2client.client-module.html">Module&nbsp;client</a> ::
39 Class&nbsp;AccessTokenCredentials
40 </span>
41 </td>
42 <td>
43 <table cellpadding="0" cellspacing="0">
44 <!-- hide/show private -->
45 <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
46 onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
47 <tr><td align="right"><span class="options"
48 >[<a href="frames.html" target="_top">frames</a
49 >]&nbsp;|&nbsp;<a href="oauth2client.client.AccessTokenCredentials-class.html"
50 target="_top">no&nbsp;frames</a>]</span></td></tr>
51 </table>
52 </td>
53 </tr>
54</table>
55<!-- ==================== CLASS DESCRIPTION ==================== -->
56<h1 class="epydoc">Class AccessTokenCredentials</h1><p class="nomargin-top"><span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials">source&nbsp;code</a></span></p>
57<center>
58<center> <map id="uml_class_diagram_for_oauth2cl_10" name="uml_class_diagram_for_oauth2cl_10">
59<area shape="rect" href="oauth2client.client.AccessTokenCredentials-class.html#__init__" title="Create an instance of OAuth2Credentials" alt="" coords="17,324,257,343"/>
60<area shape="rect" href="oauth2client.client.AccessTokenCredentials-class.html#from_json" title="Instantiate a Credentials object from a JSON description of it." alt="" coords="17,343,257,361"/>
61<area shape="rect" href="oauth2client.client.AccessTokenCredentials-class.html" title="Credentials object for OAuth 2.0." alt="" coords="16,299,259,363"/>
62<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#access_token_expired" title="True if the credential is expired or invalid." alt="" coords="64,116,211,135"/>
63<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#authorize" title="Authorize an httplib2.Http instance with these credentials." alt="" coords="64,137,211,156"/>
64<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#refresh" title="Forces a refresh of the access_token." alt="" coords="64,156,211,175"/>
65<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#apply" title="Add the authorization to the headers." alt="" coords="64,175,211,193"/>
66<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#to_json" title="Creating a JSON representation of an instance of Credentials." alt="" coords="64,193,211,212"/>
67<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#set_store" title="Set the Storage for the credential." alt="" coords="64,212,211,231"/>
68<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#__getstate__" title="Trim the state down to something that can be pickled." alt="" coords="64,231,211,249"/>
69<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html#__setstate__" title="Reconstitute the state of the object from being pickled." alt="" coords="64,249,211,268"/>
70<area shape="rect" href="oauth2client.client.OAuth2Credentials-class.html" title="Credentials object for OAuth 2.0." alt="" coords="63,99,212,269"/>
71<area shape="rect" href="oauth2client.client.Credentials-class.html#NON_SERIALIZED_MEMBERS" title="oauth2client.client.Credentials.NON_SERIALIZED_MEMBERS" alt="" coords="43,28,232,47"/>
72<area shape="rect" href="oauth2client.client.Credentials-class.html#new_from_json" title="Utility class method to instantiate a Credentials subclass from a JSON representation produced by to_json()." alt="" coords="43,49,232,68"/>
73<area shape="rect" href="oauth2client.client.Credentials-class.html" title="Base class for all Credentials objects." alt="" coords="41,11,233,69"/>
74</map>
75 <img src="uml_class_diagram_for_oauth2cl_10.gif" alt='' usemap="#uml_class_diagram_for_oauth2cl_10" ismap="ismap" class="graph-without-title" />
76</center>
77</center>
78<hr />
79<pre class="literalblock">
80Credentials object for OAuth 2.0.
81
82Credentials can be applied to an httplib2.Http object using the
83authorize() method, which then signs each request from that object
84with the OAuth 2.0 access token. This set of credentials is for the
85use case where you have acquired an OAuth 2.0 access_token from
86another place such as a JavaScript client or another web
87application, and wish to use it from Python. Because only the
88access_token is present it can not be refreshed and will in time
89expire.
90
91AccessTokenCredentials objects may be safely pickled and unpickled.
92
93Usage:
94 credentials = AccessTokenCredentials('&lt;an access token&gt;',
95 'my-user-agent/1.0')
96 http = httplib2.Http()
97 http = credentials.authorize(http)
98
99Exceptions:
100 AccessTokenCredentialsExpired: raised when the access_token expires or is
101 revoked.
102
103</pre>
104
105<!-- ==================== INSTANCE METHODS ==================== -->
106<a name="section-InstanceMethods"></a>
107<table class="summary" border="1" cellpadding="3"
108 cellspacing="0" width="100%" bgcolor="white">
109<tr bgcolor="#70b0f0" class="table-header">
110 <td colspan="2" class="table-header">
111 <table border="0" cellpadding="0" cellspacing="0" width="100%">
112 <tr valign="top">
113 <td align="left"><span class="table-header">Instance Methods</span></td>
114 <td align="right" valign="top"
115 ><span class="options">[<a href="#section-InstanceMethods"
116 class="privatelink" onclick="toggle_private();"
117 >hide private</a>]</span></td>
118 </tr>
119 </table>
120 </td>
121</tr>
122<tr>
123 <td width="15%" align="right" valign="top" class="summary">
124 <span class="summary-type">&nbsp;</span>
125 </td><td class="summary">
126 <table width="100%" cellpadding="0" cellspacing="0" border="0">
127 <tr>
128 <td><span class="summary-sig"><a href="oauth2client.client.AccessTokenCredentials-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
129 <span class="summary-sig-arg">access_token</span>,
130 <span class="summary-sig-arg">user_agent</span>)</span><br />
131 Create an instance of OAuth2Credentials</td>
132 <td align="right" valign="top">
133 <span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials.__init__">source&nbsp;code</a></span>
134
135 </td>
136 </tr>
137 </table>
138
139 </td>
140 </tr>
141<tr class="private">
142 <td width="15%" align="right" valign="top" class="summary">
143 <span class="summary-type">&nbsp;</span>
144 </td><td class="summary">
145 <table width="100%" cellpadding="0" cellspacing="0" border="0">
146 <tr>
147 <td><span class="summary-sig"><a href="oauth2client.client.AccessTokenCredentials-class.html#_refresh" class="summary-sig-name" onclick="show_private();">_refresh</a>(<span class="summary-sig-arg">self</span>,
148 <span class="summary-sig-arg">http_request</span>)</span><br />
149 Refreshes the access_token.</td>
150 <td align="right" valign="top">
151 <span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials._refresh">source&nbsp;code</a></span>
152
153 </td>
154 </tr>
155 </table>
156
157 </td>
158 </tr>
159 <tr>
160 <td colspan="2" class="summary">
161 <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.OAuth2Credentials-class.html">OAuth2Credentials</a></code></b>:
162 <code><a href="oauth2client.client.OAuth2Credentials-class.html#__getstate__">__getstate__</a></code>,
163 <code><a href="oauth2client.client.OAuth2Credentials-class.html#__setstate__">__setstate__</a></code>,
164 <code><a href="oauth2client.client.OAuth2Credentials-class.html#apply">apply</a></code>,
165 <code><a href="oauth2client.client.OAuth2Credentials-class.html#authorize">authorize</a></code>,
166 <code><a href="oauth2client.client.OAuth2Credentials-class.html#refresh">refresh</a></code>,
167 <code><a href="oauth2client.client.OAuth2Credentials-class.html#set_store">set_store</a></code>,
168 <code><a href="oauth2client.client.OAuth2Credentials-class.html#to_json">to_json</a></code>
169 </p>
170 <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.OAuth2Credentials-class.html">OAuth2Credentials</a></code></b> (private):
171 <code><a href="oauth2client.client.OAuth2Credentials-class.html#_do_refresh_request" onclick="show_private();">_do_refresh_request</a></code>,
172 <code><a href="oauth2client.client.OAuth2Credentials-class.html#_generate_refresh_request_body" onclick="show_private();">_generate_refresh_request_body</a></code>,
173 <code><a href="oauth2client.client.OAuth2Credentials-class.html#_generate_refresh_request_headers" onclick="show_private();">_generate_refresh_request_headers</a></code>,
174 <code><a href="oauth2client.client.OAuth2Credentials-class.html#_updateFromCredential" onclick="show_private();">_updateFromCredential</a></code>
175 </p></div>
176 <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.Credentials-class.html">Credentials</a></code></b> (private):
177 <code><a href="oauth2client.client.Credentials-class.html#_to_json" onclick="show_private();">_to_json</a></code>
178 </p></div>
179 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
180 <code>__delattr__</code>,
181 <code>__format__</code>,
182 <code>__getattribute__</code>,
183 <code>__hash__</code>,
184 <code>__new__</code>,
185 <code>__reduce__</code>,
186 <code>__reduce_ex__</code>,
187 <code>__repr__</code>,
188 <code>__setattr__</code>,
189 <code>__sizeof__</code>,
190 <code>__str__</code>,
191 <code>__subclasshook__</code>
192 </p>
193 </td>
194 </tr>
195</table>
196<!-- ==================== CLASS METHODS ==================== -->
197<a name="section-ClassMethods"></a>
198<table class="summary" border="1" cellpadding="3"
199 cellspacing="0" width="100%" bgcolor="white">
200<tr bgcolor="#70b0f0" class="table-header">
201 <td colspan="2" class="table-header">
202 <table border="0" cellpadding="0" cellspacing="0" width="100%">
203 <tr valign="top">
204 <td align="left"><span class="table-header">Class Methods</span></td>
205 <td align="right" valign="top"
206 ><span class="options">[<a href="#section-ClassMethods"
207 class="privatelink" onclick="toggle_private();"
208 >hide private</a>]</span></td>
209 </tr>
210 </table>
211 </td>
212</tr>
213<tr>
214 <td width="15%" align="right" valign="top" class="summary">
215 <span class="summary-type">&nbsp;</span>
216 </td><td class="summary">
217 <table width="100%" cellpadding="0" cellspacing="0" border="0">
218 <tr>
219 <td><span class="summary-sig"><a href="oauth2client.client.AccessTokenCredentials-class.html#from_json" class="summary-sig-name">from_json</a>(<span class="summary-sig-arg">cls</span>,
220 <span class="summary-sig-arg">s</span>)</span><br />
221 Instantiate a Credentials object from a JSON description of it.</td>
222 <td align="right" valign="top">
223 <span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials.from_json">source&nbsp;code</a></span>
224
225 </td>
226 </tr>
227 </table>
228
229 </td>
230 </tr>
231 <tr>
232 <td colspan="2" class="summary">
233 <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.Credentials-class.html">Credentials</a></code></b>:
234 <code><a href="oauth2client.client.Credentials-class.html#new_from_json">new_from_json</a></code>
235 </p>
236 </td>
237 </tr>
238</table>
239<!-- ==================== CLASS VARIABLES ==================== -->
240<a name="section-ClassVariables"></a>
241<table class="summary" border="1" cellpadding="3"
242 cellspacing="0" width="100%" bgcolor="white">
243<tr bgcolor="#70b0f0" class="table-header">
244 <td colspan="2" class="table-header">
245 <table border="0" cellpadding="0" cellspacing="0" width="100%">
246 <tr valign="top">
247 <td align="left"><span class="table-header">Class Variables</span></td>
248 <td align="right" valign="top"
249 ><span class="options">[<a href="#section-ClassVariables"
250 class="privatelink" onclick="toggle_private();"
251 >hide private</a>]</span></td>
252 </tr>
253 </table>
254 </td>
255</tr>
256 <tr>
257 <td colspan="2" class="summary">
258 <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.Credentials-class.html">Credentials</a></code></b>:
259 <code><a href="oauth2client.client.Credentials-class.html#NON_SERIALIZED_MEMBERS">NON_SERIALIZED_MEMBERS</a></code>
260 </p>
261 </td>
262 </tr>
263</table>
264<!-- ==================== PROPERTIES ==================== -->
265<a name="section-Properties"></a>
266<table class="summary" border="1" cellpadding="3"
267 cellspacing="0" width="100%" bgcolor="white">
268<tr bgcolor="#70b0f0" class="table-header">
269 <td colspan="2" class="table-header">
270 <table border="0" cellpadding="0" cellspacing="0" width="100%">
271 <tr valign="top">
272 <td align="left"><span class="table-header">Properties</span></td>
273 <td align="right" valign="top"
274 ><span class="options">[<a href="#section-Properties"
275 class="privatelink" onclick="toggle_private();"
276 >hide private</a>]</span></td>
277 </tr>
278 </table>
279 </td>
280</tr>
281 <tr>
282 <td colspan="2" class="summary">
283 <p class="indent-wrapped-lines"><b>Inherited from <code><a href="oauth2client.client.OAuth2Credentials-class.html">OAuth2Credentials</a></code></b>:
284 <code><a href="oauth2client.client.OAuth2Credentials-class.html#access_token_expired">access_token_expired</a></code>
285 </p>
286 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
287 <code>__class__</code>
288 </p>
289 </td>
290 </tr>
291</table>
292<!-- ==================== METHOD DETAILS ==================== -->
293<a name="section-MethodDetails"></a>
294<table class="details" border="1" cellpadding="3"
295 cellspacing="0" width="100%" bgcolor="white">
296<tr bgcolor="#70b0f0" class="table-header">
297 <td colspan="2" class="table-header">
298 <table border="0" cellpadding="0" cellspacing="0" width="100%">
299 <tr valign="top">
300 <td align="left"><span class="table-header">Method Details</span></td>
301 <td align="right" valign="top"
302 ><span class="options">[<a href="#section-MethodDetails"
303 class="privatelink" onclick="toggle_private();"
304 >hide private</a>]</span></td>
305 </tr>
306 </table>
307 </td>
308</tr>
309</table>
310<a name="__init__"></a>
311<div>
312<table class="details" border="1" cellpadding="3"
313 cellspacing="0" width="100%" bgcolor="white">
314<tr><td>
315 <table width="100%" cellpadding="0" cellspacing="0" border="0">
316 <tr valign="top"><td>
317 <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
318 <span class="sig-arg">access_token</span>,
319 <span class="sig-arg">user_agent</span>)</span>
320 <br /><em class="fname">(Constructor)</em>
321 </h3>
322 </td><td align="right" valign="top"
323 ><span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials.__init__">source&nbsp;code</a></span>&nbsp;
324 </td>
325 </tr></table>
326
327 <pre class="literalblock">
328Create an instance of OAuth2Credentials
329
330This is one of the few types if Credentials that you should contrust,
331Credentials objects are usually instantiated by a Flow.
332
333Args:
334 access_token: string, access token.
335 user_agent: string, The HTTP User-Agent to provide for this application.
336
337Notes:
338 store: callable, a callable that when passed a Credential
339 will store the credential back to where it came from.
340
341</pre>
342 <dl class="fields">
343 <dt>Overrides:
344 object.__init__
345 </dt>
346 </dl>
347</td></tr></table>
348</div>
349<a name="from_json"></a>
350<div>
351<table class="details" border="1" cellpadding="3"
352 cellspacing="0" width="100%" bgcolor="white">
353<tr><td>
354 <table width="100%" cellpadding="0" cellspacing="0" border="0">
355 <tr valign="top"><td>
356 <h3 class="epydoc"><span class="sig"><span class="sig-name">from_json</span>(<span class="sig-arg">cls</span>,
357 <span class="sig-arg">s</span>)</span>
358 <br /><em class="fname">Class Method</em>
359 </h3>
360 </td><td align="right" valign="top"
361 ><span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials.from_json">source&nbsp;code</a></span>&nbsp;
362 </td>
363 </tr></table>
364
365 <pre class="literalblock">
366Instantiate a Credentials object from a JSON description of it. The JSON
367should have been produced by calling .to_json() on the object.
368
369Args:
370 data: dict, A deserialized JSON object.
371
372Returns:
373 An instance of a Credentials subclass.
374
375</pre>
376 <dl class="fields">
377 <dt>Overrides:
378 <a href="oauth2client.client.Credentials-class.html#from_json">Credentials.from_json</a>
379 <dd><em class="note">(inherited documentation)</em></dd>
380 </dt>
381 </dl>
382</td></tr></table>
383</div>
384<a name="_refresh"></a>
385<div class="private">
386<table class="details" border="1" cellpadding="3"
387 cellspacing="0" width="100%" bgcolor="white">
388<tr><td>
389 <table width="100%" cellpadding="0" cellspacing="0" border="0">
390 <tr valign="top"><td>
391 <h3 class="epydoc"><span class="sig"><span class="sig-name">_refresh</span>(<span class="sig-arg">self</span>,
392 <span class="sig-arg">http_request</span>)</span>
393 </h3>
394 </td><td align="right" valign="top"
395 ><span class="codelink"><a href="oauth2client.client-pysrc.html#AccessTokenCredentials._refresh">source&nbsp;code</a></span>&nbsp;
396 </td>
397 </tr></table>
398
399 <pre class="literalblock">
400Refreshes the access_token.
401
402This method first checks by reading the Storage object if available.
403If a refresh is still needed, it holds the Storage lock until the
404refresh is completed.
405
406Args:
407 http_request: callable, a callable that matches the method signature of
408 httplib2.Http.request, used to make the refresh request.
409
410Raises:
411 AccessTokenRefreshError: When the refresh fails.
412
413</pre>
414 <dl class="fields">
415 <dt>Overrides:
416 <a href="oauth2client.client.OAuth2Credentials-class.html#_refresh" onclick="show_private();">OAuth2Credentials._refresh</a>
417 <dd><em class="note">(inherited documentation)</em></dd>
418 </dt>
419 </dl>
420</td></tr></table>
421</div>
422<br />
423<!-- ==================== NAVIGATION BAR ==================== -->
424<table class="navbar" border="0" width="100%" cellpadding="0"
425 bgcolor="#a0c0ff" cellspacing="0">
426 <tr valign="middle">
427
428 <!-- Tree link -->
429 <th>&nbsp;&nbsp;&nbsp;<a
430 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
431
432 <!-- Index link -->
433 <th>&nbsp;&nbsp;&nbsp;<a
434 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
435
436 <!-- Help link -->
437 <th>&nbsp;&nbsp;&nbsp;<a
438 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
439
440 <th class="navbar" width="100%"></th>
441 </tr>
442</table>
443<table border="0" cellpadding="0" cellspacing="0" width="100%%">
444 <tr>
445 <td align="left" class="footer">
Joe Gregorio66212032012-06-14 09:10:14 -0400446 Generated by Epydoc 3.0.1 on Thu Jun 14 08:01:57 2012
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400447 </td>
448 <td align="right" class="footer">
449 <a target="mainFrame" href="http://epydoc.sourceforge.net"
450 >http://epydoc.sourceforge.net</a>
451 </td>
452 </tr>
453</table>
454
455<script type="text/javascript">
456 <!--
457 // Private objects are initially displayed (because if
458 // javascript is turned off then we want them to be
459 // visible); but by default, we want to hide them. So hide
460 // them unless we have a cookie that says to show them.
461 checkCookie();
462 // -->
463</script>
464</body>
465</html>