blob: e6f8885de3d0559d80e6c31d57c42094d1d6f845 [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.crypt</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 Module&nbsp;crypt
39 </span>
40 </td>
41 <td>
42 <table cellpadding="0" cellspacing="0">
43 <!-- hide/show private -->
44 <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
45 onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
46 <tr><td align="right"><span class="options"
47 >[<a href="frames.html" target="_top">frames</a
48 >]&nbsp;|&nbsp;<a href="oauth2client.crypt-pysrc.html"
49 target="_top">no&nbsp;frames</a>]</span></td></tr>
50 </table>
51 </td>
52 </tr>
53</table>
54<h1 class="epydoc">Source Code for <a href="oauth2client.crypt-module.html">Module oauth2client.crypt</a></h1>
55<pre class="py-src">
56<a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-comment">#!/usr/bin/python2.4</tt> </tt>
57<a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-comment"># -*- coding: utf-8 -*-</tt> </tt>
58<a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
59<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-comment"># Copyright (C) 2011 Google Inc.</tt> </tt>
60<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
61<a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-comment"># Licensed under the Apache License, Version 2.0 (the "License");</tt> </tt>
62<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-comment"># you may not use this file except in compliance with the License.</tt> </tt>
63<a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-comment"># You may obtain a copy of the License at</tt> </tt>
64<a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
65<a name="L10"></a><tt class="py-lineno"> 10</tt> <tt class="py-line"><tt class="py-comment"># http://www.apache.org/licenses/LICENSE-2.0</tt> </tt>
66<a name="L11"></a><tt class="py-lineno"> 11</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
67<a name="L12"></a><tt class="py-lineno"> 12</tt> <tt class="py-line"><tt class="py-comment"># Unless required by applicable law or agreed to in writing, software</tt> </tt>
68<a name="L13"></a><tt class="py-lineno"> 13</tt> <tt class="py-line"><tt class="py-comment"># distributed under the License is distributed on an "AS IS" BASIS,</tt> </tt>
69<a name="L14"></a><tt class="py-lineno"> 14</tt> <tt class="py-line"><tt class="py-comment"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</tt> </tt>
70<a name="L15"></a><tt class="py-lineno"> 15</tt> <tt class="py-line"><tt class="py-comment"># See the License for the specific language governing permissions and</tt> </tt>
71<a name="L16"></a><tt class="py-lineno"> 16</tt> <tt class="py-line"><tt class="py-comment"># limitations under the License.</tt> </tt>
72<a name="L17"></a><tt class="py-lineno"> 17</tt> <tt class="py-line"> </tt>
73<a name="L18"></a><tt class="py-lineno"> 18</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">base64</tt> </tt>
74<a name="L19"></a><tt class="py-lineno"> 19</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">hashlib</tt> </tt>
75<a name="L20"></a><tt class="py-lineno"> 20</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">logging</tt> </tt>
76<a name="L21"></a><tt class="py-lineno"> 21</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">time</tt> </tt>
77<a name="L22"></a><tt class="py-lineno"> 22</tt> <tt class="py-line"> </tt>
78<a name="L23"></a><tt class="py-lineno"> 23</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">OpenSSL</tt> <tt class="py-keyword">import</tt> <tt class="py-name">crypto</tt> </tt>
79<a name="L24"></a><tt class="py-lineno"> 24</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Module oauth2client.anyjson=oauth2client.anyjson-module.html"><a title="oauth2client.anyjson" class="py-name" href="#" onclick="return doclink('link-0', 'anyjson', 'link-0');">anyjson</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">simplejson</tt> </tt>
80<a name="L25"></a><tt class="py-lineno"> 25</tt> <tt class="py-line"> </tt>
81<a name="L26"></a><tt class="py-lineno"> 26</tt> <tt class="py-line"> </tt>
Joe Gregorio1b425aa2012-08-24 12:04:34 -040082<a name="L27"></a><tt class="py-lineno"> 27</tt> <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable apiclient.discovery.logger=apiclient.discovery-module.html#logger,Variable oauth2client.appengine.logger=oauth2client.appengine-module.html#logger,Variable oauth2client.client.logger=oauth2client.client-module.html#logger,Variable oauth2client.crypt.logger=oauth2client.crypt-module.html#logger,Variable oauth2client.gce.logger=oauth2client.gce-module.html#logger,Variable oauth2client.locked_file.logger=oauth2client.locked_file-module.html#logger,Variable oauth2client.multistore_file.logger=oauth2client.multistore_file-module.html#logger,Variable oauth2client.util.logger=oauth2client.util-module.html#logger"><a title="apiclient.discovery.logger
Joe Gregorioe7a0c472012-07-12 11:46:04 -040083oauth2client.appengine.logger
84oauth2client.client.logger
85oauth2client.crypt.logger
Joe Gregorio1b425aa2012-08-24 12:04:34 -040086oauth2client.gce.logger
Joe Gregorioe7a0c472012-07-12 11:46:04 -040087oauth2client.locked_file.logger
Joe Gregorioad8013f2012-08-03 08:44:02 -040088oauth2client.multistore_file.logger
89oauth2client.util.logger" class="py-name" href="#" onclick="return doclink('link-1', 'logger', 'link-1');">logger</a></tt> <tt class="py-op">=</tt> <tt class="py-name">logging</tt><tt class="py-op">.</tt><tt class="py-name">getLogger</tt><tt class="py-op">(</tt><tt class="py-name">__name__</tt><tt class="py-op">)</tt> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -040090<a name="L28"></a><tt class="py-lineno"> 28</tt> <tt class="py-line"> </tt>
91<a name="L29"></a><tt class="py-lineno"> 29</tt> <tt class="py-line"><tt id="link-2" class="py-name" targets="Variable oauth2client.crypt.CLOCK_SKEW_SECS=oauth2client.crypt-module.html#CLOCK_SKEW_SECS"><a title="oauth2client.crypt.CLOCK_SKEW_SECS" class="py-name" href="#" onclick="return doclink('link-2', 'CLOCK_SKEW_SECS', 'link-2');">CLOCK_SKEW_SECS</a></tt> <tt class="py-op">=</tt> <tt class="py-number">300</tt> <tt class="py-comment"># 5 minutes in seconds</tt> </tt>
92<a name="L30"></a><tt class="py-lineno"> 30</tt> <tt class="py-line"><tt id="link-3" class="py-name" targets="Variable oauth2client.crypt.AUTH_TOKEN_LIFETIME_SECS=oauth2client.crypt-module.html#AUTH_TOKEN_LIFETIME_SECS"><a title="oauth2client.crypt.AUTH_TOKEN_LIFETIME_SECS" class="py-name" href="#" onclick="return doclink('link-3', 'AUTH_TOKEN_LIFETIME_SECS', 'link-3');">AUTH_TOKEN_LIFETIME_SECS</a></tt> <tt class="py-op">=</tt> <tt class="py-number">300</tt> <tt class="py-comment"># 5 minutes in seconds</tt> </tt>
93<a name="L31"></a><tt class="py-lineno"> 31</tt> <tt class="py-line"><tt id="link-4" class="py-name" targets="Variable oauth2client.client.SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS=oauth2client.client.SignedJwtAssertionCredentials-class.html#MAX_TOKEN_LIFETIME_SECS,Variable oauth2client.crypt.MAX_TOKEN_LIFETIME_SECS=oauth2client.crypt-module.html#MAX_TOKEN_LIFETIME_SECS"><a title="oauth2client.client.SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS
94oauth2client.crypt.MAX_TOKEN_LIFETIME_SECS" class="py-name" href="#" onclick="return doclink('link-4', 'MAX_TOKEN_LIFETIME_SECS', 'link-4');">MAX_TOKEN_LIFETIME_SECS</a></tt> <tt class="py-op">=</tt> <tt class="py-number">86400</tt> <tt class="py-comment"># 1 day in seconds</tt> </tt>
95<a name="AppIdentityError"></a><div id="AppIdentityError-def"><a name="L32"></a><tt class="py-lineno"> 32</tt> <tt class="py-line"> </tt>
96<a name="L33"></a><tt class="py-lineno"> 33</tt> <tt class="py-line"> </tt>
97<a name="L34"></a><tt class="py-lineno"> 34</tt> <a class="py-toggle" href="#" id="AppIdentityError-toggle" onclick="return toggle('AppIdentityError');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="oauth2client.crypt.AppIdentityError-class.html">AppIdentityError</a><tt class="py-op">(</tt><tt class="py-base-class">Exception</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
98</div><div id="AppIdentityError-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="AppIdentityError-expanded"><a name="L35"></a><tt class="py-lineno"> 35</tt> <tt class="py-line"> <tt class="py-keyword">pass</tt> </tt>
99</div><a name="L36"></a><tt class="py-lineno"> 36</tt> <tt class="py-line"> </tt>
100<a name="Verifier"></a><div id="Verifier-def"><a name="L37"></a><tt class="py-lineno"> 37</tt> <tt class="py-line"> </tt>
101<a name="L38"></a><tt class="py-lineno"> 38</tt> <a class="py-toggle" href="#" id="Verifier-toggle" onclick="return toggle('Verifier');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="oauth2client.crypt.Verifier-class.html">Verifier</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
102</div><div id="Verifier-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Verifier-expanded"><a name="L39"></a><tt class="py-lineno"> 39</tt> <tt class="py-line"> <tt class="py-docstring">"""Verifies the signature on a message."""</tt> </tt>
103<a name="L40"></a><tt class="py-lineno"> 40</tt> <tt class="py-line"> </tt>
104<a name="Verifier.__init__"></a><div id="Verifier.__init__-def"><a name="L41"></a><tt class="py-lineno"> 41</tt> <a class="py-toggle" href="#" id="Verifier.__init__-toggle" onclick="return toggle('Verifier.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Verifier-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">pubkey</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
105</div><div id="Verifier.__init__-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Verifier.__init__-expanded"><a name="L42"></a><tt class="py-lineno"> 42</tt> <tt class="py-line"> <tt class="py-docstring">"""Constructor.</tt> </tt>
106<a name="L43"></a><tt class="py-lineno"> 43</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
107<a name="L44"></a><tt class="py-lineno"> 44</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
108<a name="L45"></a><tt class="py-lineno"> 45</tt> <tt class="py-line"><tt class="py-docstring"> pubkey, OpenSSL.crypto.PKey, The public key to verify with.</tt> </tt>
109<a name="L46"></a><tt class="py-lineno"> 46</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
110<a name="L47"></a><tt class="py-lineno"> 47</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_pubkey</tt> <tt class="py-op">=</tt> <tt class="py-name">pubkey</tt> </tt>
111</div><a name="L48"></a><tt class="py-lineno"> 48</tt> <tt class="py-line"> </tt>
112<a name="Verifier.verify"></a><div id="Verifier.verify-def"><a name="L49"></a><tt class="py-lineno"> 49</tt> <a class="py-toggle" href="#" id="Verifier.verify-toggle" onclick="return toggle('Verifier.verify');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Verifier-class.html#verify">verify</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">message</tt><tt class="py-op">,</tt> <tt class="py-param">signature</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
113</div><div id="Verifier.verify-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Verifier.verify-expanded"><a name="L50"></a><tt class="py-lineno"> 50</tt> <tt class="py-line"> <tt class="py-docstring">"""Verifies a message against a signature.</tt> </tt>
114<a name="L51"></a><tt class="py-lineno"> 51</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
115<a name="L52"></a><tt class="py-lineno"> 52</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
116<a name="L53"></a><tt class="py-lineno"> 53</tt> <tt class="py-line"><tt class="py-docstring"> message: string, The message to verify.</tt> </tt>
117<a name="L54"></a><tt class="py-lineno"> 54</tt> <tt class="py-line"><tt class="py-docstring"> signature: string, The signature on the message.</tt> </tt>
118<a name="L55"></a><tt class="py-lineno"> 55</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
119<a name="L56"></a><tt class="py-lineno"> 56</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
120<a name="L57"></a><tt class="py-lineno"> 57</tt> <tt class="py-line"><tt class="py-docstring"> True if message was singed by the private key associated with the public</tt> </tt>
121<a name="L58"></a><tt class="py-lineno"> 58</tt> <tt class="py-line"><tt class="py-docstring"> key that this object was constructed with.</tt> </tt>
122<a name="L59"></a><tt class="py-lineno"> 59</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
123<a name="L60"></a><tt class="py-lineno"> 60</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
124<a name="L61"></a><tt class="py-lineno"> 61</tt> <tt class="py-line"> <tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Method oauth2client.crypt.Verifier.verify()=oauth2client.crypt.Verifier-class.html#verify"><a title="oauth2client.crypt.Verifier.verify" class="py-name" href="#" onclick="return doclink('link-5', 'verify', 'link-5');">verify</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_pubkey</tt><tt class="py-op">,</tt> <tt class="py-name">signature</tt><tt class="py-op">,</tt> <tt class="py-name">message</tt><tt class="py-op">,</tt> <tt class="py-string">'sha256'</tt><tt class="py-op">)</tt> </tt>
125<a name="L62"></a><tt class="py-lineno"> 62</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
126<a name="L63"></a><tt class="py-lineno"> 63</tt> <tt class="py-line"> <tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
127<a name="L64"></a><tt class="py-lineno"> 64</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">False</tt> </tt>
128</div><a name="L65"></a><tt class="py-lineno"> 65</tt> <tt class="py-line"> </tt>
129<a name="L66"></a><tt class="py-lineno"> 66</tt> <tt class="py-line"> <tt class="py-decorator">@</tt><tt class="py-decorator">staticmethod</tt> </tt>
130<a name="Verifier.from_string"></a><div id="Verifier.from_string-def"><a name="L67"></a><tt class="py-lineno"> 67</tt> <a class="py-toggle" href="#" id="Verifier.from_string-toggle" onclick="return toggle('Verifier.from_string');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Verifier-class.html#from_string">from_string</a><tt class="py-op">(</tt><tt class="py-param">key_pem</tt><tt class="py-op">,</tt> <tt class="py-param">is_x509_cert</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
131</div><div id="Verifier.from_string-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Verifier.from_string-expanded"><a name="L68"></a><tt class="py-lineno"> 68</tt> <tt class="py-line"> <tt class="py-docstring">"""Construct a Verified instance from a string.</tt> </tt>
132<a name="L69"></a><tt class="py-lineno"> 69</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
133<a name="L70"></a><tt class="py-lineno"> 70</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
134<a name="L71"></a><tt class="py-lineno"> 71</tt> <tt class="py-line"><tt class="py-docstring"> key_pem: string, public key in PEM format.</tt> </tt>
135<a name="L72"></a><tt class="py-lineno"> 72</tt> <tt class="py-line"><tt class="py-docstring"> is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it is</tt> </tt>
136<a name="L73"></a><tt class="py-lineno"> 73</tt> <tt class="py-line"><tt class="py-docstring"> expected to be an RSA key in PEM format.</tt> </tt>
137<a name="L74"></a><tt class="py-lineno"> 74</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
138<a name="L75"></a><tt class="py-lineno"> 75</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
139<a name="L76"></a><tt class="py-lineno"> 76</tt> <tt class="py-line"><tt class="py-docstring"> Verifier instance.</tt> </tt>
140<a name="L77"></a><tt class="py-lineno"> 77</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
141<a name="L78"></a><tt class="py-lineno"> 78</tt> <tt class="py-line"><tt class="py-docstring"> Raises:</tt> </tt>
142<a name="L79"></a><tt class="py-lineno"> 79</tt> <tt class="py-line"><tt class="py-docstring"> OpenSSL.crypto.Error if the key_pem can't be parsed.</tt> </tt>
143<a name="L80"></a><tt class="py-lineno"> 80</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
144<a name="L81"></a><tt class="py-lineno"> 81</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">is_x509_cert</tt><tt class="py-op">:</tt> </tt>
145<a name="L82"></a><tt class="py-lineno"> 82</tt> <tt class="py-line"> <tt class="py-name">pubkey</tt> <tt class="py-op">=</tt> <tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt class="py-name">load_certificate</tt><tt class="py-op">(</tt><tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt class="py-name">FILETYPE_PEM</tt><tt class="py-op">,</tt> <tt class="py-name">key_pem</tt><tt class="py-op">)</tt> </tt>
146<a name="L83"></a><tt class="py-lineno"> 83</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
147<a name="L84"></a><tt class="py-lineno"> 84</tt> <tt class="py-line"> <tt class="py-name">pubkey</tt> <tt class="py-op">=</tt> <tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt class="py-name">load_privatekey</tt><tt class="py-op">(</tt><tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt class="py-name">FILETYPE_PEM</tt><tt class="py-op">,</tt> <tt class="py-name">key_pem</tt><tt class="py-op">)</tt> </tt>
148<a name="L85"></a><tt class="py-lineno"> 85</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-6" class="py-name" targets="Class oauth2client.crypt.Verifier=oauth2client.crypt.Verifier-class.html"><a title="oauth2client.crypt.Verifier" class="py-name" href="#" onclick="return doclink('link-6', 'Verifier', 'link-6');">Verifier</a></tt><tt class="py-op">(</tt><tt class="py-name">pubkey</tt><tt class="py-op">)</tt> </tt>
149</div></div><a name="L86"></a><tt class="py-lineno"> 86</tt> <tt class="py-line"> </tt>
150<a name="Signer"></a><div id="Signer-def"><a name="L87"></a><tt class="py-lineno"> 87</tt> <tt class="py-line"> </tt>
151<a name="L88"></a><tt class="py-lineno"> 88</tt> <a class="py-toggle" href="#" id="Signer-toggle" onclick="return toggle('Signer');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="oauth2client.crypt.Signer-class.html">Signer</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
152</div><div id="Signer-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Signer-expanded"><a name="L89"></a><tt class="py-lineno"> 89</tt> <tt class="py-line"> <tt class="py-docstring">"""Signs messages with a private key."""</tt> </tt>
153<a name="L90"></a><tt class="py-lineno"> 90</tt> <tt class="py-line"> </tt>
154<a name="Signer.__init__"></a><div id="Signer.__init__-def"><a name="L91"></a><tt class="py-lineno"> 91</tt> <a class="py-toggle" href="#" id="Signer.__init__-toggle" onclick="return toggle('Signer.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Signer-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">pkey</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
155</div><div id="Signer.__init__-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Signer.__init__-expanded"><a name="L92"></a><tt class="py-lineno"> 92</tt> <tt class="py-line"> <tt class="py-docstring">"""Constructor.</tt> </tt>
156<a name="L93"></a><tt class="py-lineno"> 93</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
157<a name="L94"></a><tt class="py-lineno"> 94</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
158<a name="L95"></a><tt class="py-lineno"> 95</tt> <tt class="py-line"><tt class="py-docstring"> pkey, OpenSSL.crypto.PKey, The private key to sign with.</tt> </tt>
159<a name="L96"></a><tt class="py-lineno"> 96</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
160<a name="L97"></a><tt class="py-lineno"> 97</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_key</tt> <tt class="py-op">=</tt> <tt class="py-name">pkey</tt> </tt>
161</div><a name="L98"></a><tt class="py-lineno"> 98</tt> <tt class="py-line"> </tt>
162<a name="Signer.sign"></a><div id="Signer.sign-def"><a name="L99"></a><tt class="py-lineno"> 99</tt> <a class="py-toggle" href="#" id="Signer.sign-toggle" onclick="return toggle('Signer.sign');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Signer-class.html#sign">sign</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">message</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
163</div><div id="Signer.sign-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Signer.sign-expanded"><a name="L100"></a><tt class="py-lineno">100</tt> <tt class="py-line"> <tt class="py-docstring">"""Signs a message.</tt> </tt>
164<a name="L101"></a><tt class="py-lineno">101</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
165<a name="L102"></a><tt class="py-lineno">102</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
166<a name="L103"></a><tt class="py-lineno">103</tt> <tt class="py-line"><tt class="py-docstring"> message: string, Message to be signed.</tt> </tt>
167<a name="L104"></a><tt class="py-lineno">104</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
168<a name="L105"></a><tt class="py-lineno">105</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
169<a name="L106"></a><tt class="py-lineno">106</tt> <tt class="py-line"><tt class="py-docstring"> string, The signature of the message for the given key.</tt> </tt>
170<a name="L107"></a><tt class="py-lineno">107</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
171<a name="L108"></a><tt class="py-lineno">108</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name" targets="Method oauth2client.crypt.Signer.sign()=oauth2client.crypt.Signer-class.html#sign"><a title="oauth2client.crypt.Signer.sign" class="py-name" href="#" onclick="return doclink('link-7', 'sign', 'link-7');">sign</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_key</tt><tt class="py-op">,</tt> <tt class="py-name">message</tt><tt class="py-op">,</tt> <tt class="py-string">'sha256'</tt><tt class="py-op">)</tt> </tt>
172</div><a name="L109"></a><tt class="py-lineno">109</tt> <tt class="py-line"> </tt>
173<a name="L110"></a><tt class="py-lineno">110</tt> <tt class="py-line"> <tt class="py-decorator">@</tt><tt class="py-decorator">staticmethod</tt> </tt>
174<a name="Signer.from_string"></a><div id="Signer.from_string-def"><a name="L111"></a><tt class="py-lineno">111</tt> <a class="py-toggle" href="#" id="Signer.from_string-toggle" onclick="return toggle('Signer.from_string');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt.Signer-class.html#from_string">from_string</a><tt class="py-op">(</tt><tt class="py-param">key</tt><tt class="py-op">,</tt> <tt class="py-param">password</tt><tt class="py-op">=</tt><tt class="py-string">'notasecret'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
175</div><div id="Signer.from_string-collapsed" style="display:none;" pad="+++" indent="++++++"></div><div id="Signer.from_string-expanded"><a name="L112"></a><tt class="py-lineno">112</tt> <tt class="py-line"> <tt class="py-docstring">"""Construct a Signer instance from a string.</tt> </tt>
176<a name="L113"></a><tt class="py-lineno">113</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
177<a name="L114"></a><tt class="py-lineno">114</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
178<a name="L115"></a><tt class="py-lineno">115</tt> <tt class="py-line"><tt class="py-docstring"> key: string, private key in P12 format.</tt> </tt>
179<a name="L116"></a><tt class="py-lineno">116</tt> <tt class="py-line"><tt class="py-docstring"> password: string, password for the private key file.</tt> </tt>
180<a name="L117"></a><tt class="py-lineno">117</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
181<a name="L118"></a><tt class="py-lineno">118</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
182<a name="L119"></a><tt class="py-lineno">119</tt> <tt class="py-line"><tt class="py-docstring"> Signer instance.</tt> </tt>
183<a name="L120"></a><tt class="py-lineno">120</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
184<a name="L121"></a><tt class="py-lineno">121</tt> <tt class="py-line"><tt class="py-docstring"> Raises:</tt> </tt>
185<a name="L122"></a><tt class="py-lineno">122</tt> <tt class="py-line"><tt class="py-docstring"> OpenSSL.crypto.Error if the key can't be parsed.</tt> </tt>
186<a name="L123"></a><tt class="py-lineno">123</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
187<a name="L124"></a><tt class="py-lineno">124</tt> <tt class="py-line"> <tt class="py-name">pkey</tt> <tt class="py-op">=</tt> <tt class="py-name">crypto</tt><tt class="py-op">.</tt><tt class="py-name">load_pkcs12</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-name">password</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">get_privatekey</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
188<a name="L125"></a><tt class="py-lineno">125</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-8" class="py-name" targets="Class oauth2client.crypt.Signer=oauth2client.crypt.Signer-class.html"><a title="oauth2client.crypt.Signer" class="py-name" href="#" onclick="return doclink('link-8', 'Signer', 'link-8');">Signer</a></tt><tt class="py-op">(</tt><tt class="py-name">pkey</tt><tt class="py-op">)</tt> </tt>
189</div></div><a name="L126"></a><tt class="py-lineno">126</tt> <tt class="py-line"> </tt>
190<a name="_urlsafe_b64encode"></a><div id="_urlsafe_b64encode-def"><a name="L127"></a><tt class="py-lineno">127</tt> <tt class="py-line"> </tt>
191<a name="L128"></a><tt class="py-lineno">128</tt> <a class="py-toggle" href="#" id="_urlsafe_b64encode-toggle" onclick="return toggle('_urlsafe_b64encode');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt-module.html#_urlsafe_b64encode">_urlsafe_b64encode</a><tt class="py-op">(</tt><tt class="py-param">raw_bytes</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
192</div><div id="_urlsafe_b64encode-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_urlsafe_b64encode-expanded"><a name="L129"></a><tt class="py-lineno">129</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">base64</tt><tt class="py-op">.</tt><tt class="py-name">urlsafe_b64encode</tt><tt class="py-op">(</tt><tt class="py-name">raw_bytes</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">rstrip</tt><tt class="py-op">(</tt><tt class="py-string">'='</tt><tt class="py-op">)</tt> </tt>
193</div><a name="L130"></a><tt class="py-lineno">130</tt> <tt class="py-line"> </tt>
194<a name="_urlsafe_b64decode"></a><div id="_urlsafe_b64decode-def"><a name="L131"></a><tt class="py-lineno">131</tt> <tt class="py-line"> </tt>
195<a name="L132"></a><tt class="py-lineno">132</tt> <a class="py-toggle" href="#" id="_urlsafe_b64decode-toggle" onclick="return toggle('_urlsafe_b64decode');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt-module.html#_urlsafe_b64decode">_urlsafe_b64decode</a><tt class="py-op">(</tt><tt class="py-param">b64string</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
196</div><div id="_urlsafe_b64decode-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_urlsafe_b64decode-expanded"><a name="L133"></a><tt class="py-lineno">133</tt> <tt class="py-line"> <tt class="py-comment"># Guard against unicode strings, which base64 can't handle.</tt> </tt>
197<a name="L134"></a><tt class="py-lineno">134</tt> <tt class="py-line"> <tt class="py-name">b64string</tt> <tt class="py-op">=</tt> <tt class="py-name">b64string</tt><tt class="py-op">.</tt><tt class="py-name">encode</tt><tt class="py-op">(</tt><tt class="py-string">'ascii'</tt><tt class="py-op">)</tt> </tt>
198<a name="L135"></a><tt class="py-lineno">135</tt> <tt class="py-line"> <tt class="py-name">padded</tt> <tt class="py-op">=</tt> <tt class="py-name">b64string</tt> <tt class="py-op">+</tt> <tt class="py-string">'='</tt> <tt class="py-op">*</tt> <tt class="py-op">(</tt><tt class="py-number">4</tt> <tt class="py-op">-</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">b64string</tt><tt class="py-op">)</tt> <tt class="py-op">%</tt> <tt class="py-number">4</tt><tt class="py-op">)</tt> </tt>
199<a name="L136"></a><tt class="py-lineno">136</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">base64</tt><tt class="py-op">.</tt><tt class="py-name">urlsafe_b64decode</tt><tt class="py-op">(</tt><tt class="py-name">padded</tt><tt class="py-op">)</tt> </tt>
200</div><a name="L137"></a><tt class="py-lineno">137</tt> <tt class="py-line"> </tt>
201<a name="_json_encode"></a><div id="_json_encode-def"><a name="L138"></a><tt class="py-lineno">138</tt> <tt class="py-line"> </tt>
202<a name="L139"></a><tt class="py-lineno">139</tt> <a class="py-toggle" href="#" id="_json_encode-toggle" onclick="return toggle('_json_encode');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt-module.html#_json_encode">_json_encode</a><tt class="py-op">(</tt><tt class="py-param">data</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
203</div><div id="_json_encode-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_json_encode-expanded"><a name="L140"></a><tt class="py-lineno">140</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">simplejson</tt><tt class="py-op">.</tt><tt class="py-name">dumps</tt><tt class="py-op">(</tt><tt class="py-name">data</tt><tt class="py-op">,</tt> <tt class="py-name">separators</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-string">','</tt><tt class="py-op">,</tt> <tt class="py-string">':'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
204</div><a name="L141"></a><tt class="py-lineno">141</tt> <tt class="py-line"> </tt>
205<a name="make_signed_jwt"></a><div id="make_signed_jwt-def"><a name="L142"></a><tt class="py-lineno">142</tt> <tt class="py-line"> </tt>
206<a name="L143"></a><tt class="py-lineno">143</tt> <a class="py-toggle" href="#" id="make_signed_jwt-toggle" onclick="return toggle('make_signed_jwt');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt-module.html#make_signed_jwt">make_signed_jwt</a><tt class="py-op">(</tt><tt class="py-param">signer</tt><tt class="py-op">,</tt> <tt class="py-param">payload</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
207</div><div id="make_signed_jwt-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="make_signed_jwt-expanded"><a name="L144"></a><tt class="py-lineno">144</tt> <tt class="py-line"> <tt class="py-docstring">"""Make a signed JWT.</tt> </tt>
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400208<a name="L145"></a><tt class="py-lineno">145</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400209<a name="L146"></a><tt class="py-lineno">146</tt> <tt class="py-line"><tt class="py-docstring"> See http://self-issued.info/docs/draft-jones-json-web-token.html.</tt> </tt>
210<a name="L147"></a><tt class="py-lineno">147</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
211<a name="L148"></a><tt class="py-lineno">148</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
212<a name="L149"></a><tt class="py-lineno">149</tt> <tt class="py-line"><tt class="py-docstring"> signer: crypt.Signer, Cryptographic signer.</tt> </tt>
213<a name="L150"></a><tt class="py-lineno">150</tt> <tt class="py-line"><tt class="py-docstring"> payload: dict, Dictionary of data to convert to JSON and then sign.</tt> </tt>
214<a name="L151"></a><tt class="py-lineno">151</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
215<a name="L152"></a><tt class="py-lineno">152</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
216<a name="L153"></a><tt class="py-lineno">153</tt> <tt class="py-line"><tt class="py-docstring"> string, The JWT for the payload.</tt> </tt>
217<a name="L154"></a><tt class="py-lineno">154</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
218<a name="L155"></a><tt class="py-lineno">155</tt> <tt class="py-line"> <tt class="py-name">header</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-string">'typ'</tt><tt class="py-op">:</tt> <tt class="py-string">'JWT'</tt><tt class="py-op">,</tt> <tt class="py-string">'alg'</tt><tt class="py-op">:</tt> <tt class="py-string">'RS256'</tt><tt class="py-op">}</tt> </tt>
219<a name="L156"></a><tt class="py-lineno">156</tt> <tt class="py-line"> </tt>
220<a name="L157"></a><tt class="py-lineno">157</tt> <tt class="py-line"> <tt class="py-name">segments</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt> </tt>
221<a name="L158"></a><tt class="py-lineno">158</tt> <tt class="py-line"> <tt id="link-9" class="py-name" targets="Function oauth2client.crypt._urlsafe_b64encode()=oauth2client.crypt-module.html#_urlsafe_b64encode"><a title="oauth2client.crypt._urlsafe_b64encode" class="py-name" href="#" onclick="return doclink('link-9', '_urlsafe_b64encode', 'link-9');">_urlsafe_b64encode</a></tt><tt class="py-op">(</tt><tt id="link-10" class="py-name" targets="Function oauth2client.crypt._json_encode()=oauth2client.crypt-module.html#_json_encode"><a title="oauth2client.crypt._json_encode" class="py-name" href="#" onclick="return doclink('link-10', '_json_encode', 'link-10');">_json_encode</a></tt><tt class="py-op">(</tt><tt class="py-name">header</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> </tt>
222<a name="L159"></a><tt class="py-lineno">159</tt> <tt class="py-line"> <tt id="link-11" class="py-name"><a title="oauth2client.crypt._urlsafe_b64encode" class="py-name" href="#" onclick="return doclink('link-11', '_urlsafe_b64encode', 'link-9');">_urlsafe_b64encode</a></tt><tt class="py-op">(</tt><tt id="link-12" class="py-name"><a title="oauth2client.crypt._json_encode" class="py-name" href="#" onclick="return doclink('link-12', '_json_encode', 'link-10');">_json_encode</a></tt><tt class="py-op">(</tt><tt class="py-name">payload</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> </tt>
223<a name="L160"></a><tt class="py-lineno">160</tt> <tt class="py-line"> <tt class="py-op">]</tt> </tt>
224<a name="L161"></a><tt class="py-lineno">161</tt> <tt class="py-line"> <tt class="py-name">signing_input</tt> <tt class="py-op">=</tt> <tt class="py-string">'.'</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">)</tt> </tt>
225<a name="L162"></a><tt class="py-lineno">162</tt> <tt class="py-line"> </tt>
226<a name="L163"></a><tt class="py-lineno">163</tt> <tt class="py-line"> <tt class="py-name">signature</tt> <tt class="py-op">=</tt> <tt class="py-name">signer</tt><tt class="py-op">.</tt><tt id="link-13" class="py-name"><a title="oauth2client.crypt.Signer.sign" class="py-name" href="#" onclick="return doclink('link-13', 'sign', 'link-7');">sign</a></tt><tt class="py-op">(</tt><tt class="py-name">signing_input</tt><tt class="py-op">)</tt> </tt>
227<a name="L164"></a><tt class="py-lineno">164</tt> <tt class="py-line"> <tt class="py-name">segments</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt id="link-14" class="py-name"><a title="oauth2client.crypt._urlsafe_b64encode" class="py-name" href="#" onclick="return doclink('link-14', '_urlsafe_b64encode', 'link-9');">_urlsafe_b64encode</a></tt><tt class="py-op">(</tt><tt class="py-name">signature</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400228<a name="L165"></a><tt class="py-lineno">165</tt> <tt class="py-line"> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400229<a name="L166"></a><tt class="py-lineno">166</tt> <tt class="py-line"> <tt id="link-15" class="py-name"><a title="apiclient.discovery.logger
230oauth2client.appengine.logger
231oauth2client.client.logger
232oauth2client.crypt.logger
Joe Gregorio1b425aa2012-08-24 12:04:34 -0400233oauth2client.gce.logger
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400234oauth2client.locked_file.logger
Joe Gregorioad8013f2012-08-03 08:44:02 -0400235oauth2client.multistore_file.logger
236oauth2client.util.logger" class="py-name" href="#" onclick="return doclink('link-15', 'logger', 'link-1');">logger</a></tt><tt class="py-op">.</tt><tt class="py-name">debug</tt><tt class="py-op">(</tt><tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400237<a name="L167"></a><tt class="py-lineno">167</tt> <tt class="py-line"> </tt>
238<a name="L168"></a><tt class="py-lineno">168</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">'.'</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">)</tt> </tt>
239</div><a name="L169"></a><tt class="py-lineno">169</tt> <tt class="py-line"> </tt>
240<a name="verify_signed_jwt_with_certs"></a><div id="verify_signed_jwt_with_certs-def"><a name="L170"></a><tt class="py-lineno">170</tt> <tt class="py-line"> </tt>
241<a name="L171"></a><tt class="py-lineno">171</tt> <a class="py-toggle" href="#" id="verify_signed_jwt_with_certs-toggle" onclick="return toggle('verify_signed_jwt_with_certs');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="oauth2client.crypt-module.html#verify_signed_jwt_with_certs">verify_signed_jwt_with_certs</a><tt class="py-op">(</tt><tt class="py-param">jwt</tt><tt class="py-op">,</tt> <tt class="py-param">certs</tt><tt class="py-op">,</tt> <tt class="py-param">audience</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
242</div><div id="verify_signed_jwt_with_certs-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="verify_signed_jwt_with_certs-expanded"><a name="L172"></a><tt class="py-lineno">172</tt> <tt class="py-line"> <tt class="py-docstring">"""Verify a JWT against public certs.</tt> </tt>
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400243<a name="L173"></a><tt class="py-lineno">173</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400244<a name="L174"></a><tt class="py-lineno">174</tt> <tt class="py-line"><tt class="py-docstring"> See http://self-issued.info/docs/draft-jones-json-web-token.html.</tt> </tt>
245<a name="L175"></a><tt class="py-lineno">175</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
246<a name="L176"></a><tt class="py-lineno">176</tt> <tt class="py-line"><tt class="py-docstring"> Args:</tt> </tt>
247<a name="L177"></a><tt class="py-lineno">177</tt> <tt class="py-line"><tt class="py-docstring"> jwt: string, A JWT.</tt> </tt>
248<a name="L178"></a><tt class="py-lineno">178</tt> <tt class="py-line"><tt class="py-docstring"> certs: dict, Dictionary where values of public keys in PEM format.</tt> </tt>
249<a name="L179"></a><tt class="py-lineno">179</tt> <tt class="py-line"><tt class="py-docstring"> audience: string, The audience, 'aud', that this JWT should contain. If</tt> </tt>
250<a name="L180"></a><tt class="py-lineno">180</tt> <tt class="py-line"><tt class="py-docstring"> None then the JWT's 'aud' parameter is not verified.</tt> </tt>
251<a name="L181"></a><tt class="py-lineno">181</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
252<a name="L182"></a><tt class="py-lineno">182</tt> <tt class="py-line"><tt class="py-docstring"> Returns:</tt> </tt>
253<a name="L183"></a><tt class="py-lineno">183</tt> <tt class="py-line"><tt class="py-docstring"> dict, The deserialized JSON payload in the JWT.</tt> </tt>
254<a name="L184"></a><tt class="py-lineno">184</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
255<a name="L185"></a><tt class="py-lineno">185</tt> <tt class="py-line"><tt class="py-docstring"> Raises:</tt> </tt>
256<a name="L186"></a><tt class="py-lineno">186</tt> <tt class="py-line"><tt class="py-docstring"> AppIdentityError if any checks are failed.</tt> </tt>
257<a name="L187"></a><tt class="py-lineno">187</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
258<a name="L188"></a><tt class="py-lineno">188</tt> <tt class="py-line"> <tt class="py-name">segments</tt> <tt class="py-op">=</tt> <tt class="py-name">jwt</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">'.'</tt><tt class="py-op">)</tt> </tt>
259<a name="L189"></a><tt class="py-lineno">189</tt> <tt class="py-line"> </tt>
260<a name="L190"></a><tt class="py-lineno">190</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt> <tt class="py-number">3</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
261<a name="L191"></a><tt class="py-lineno">191</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-16" class="py-name" targets="Class oauth2client.crypt.AppIdentityError=oauth2client.crypt.AppIdentityError-class.html"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-16', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt> </tt>
262<a name="L192"></a><tt class="py-lineno">192</tt> <tt class="py-line"> <tt class="py-string">'Wrong number of segments in token: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">jwt</tt><tt class="py-op">)</tt> </tt>
263<a name="L193"></a><tt class="py-lineno">193</tt> <tt class="py-line"> <tt class="py-name">signed</tt> <tt class="py-op">=</tt> <tt class="py-string">'%s.%s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">segments</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400264<a name="L194"></a><tt class="py-lineno">194</tt> <tt class="py-line"> </tt>
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400265<a name="L195"></a><tt class="py-lineno">195</tt> <tt class="py-line"> <tt class="py-name">signature</tt> <tt class="py-op">=</tt> <tt id="link-17" class="py-name" targets="Function oauth2client.client._urlsafe_b64decode()=oauth2client.client-module.html#_urlsafe_b64decode,Function oauth2client.crypt._urlsafe_b64decode()=oauth2client.crypt-module.html#_urlsafe_b64decode"><a title="oauth2client.client._urlsafe_b64decode
266oauth2client.crypt._urlsafe_b64decode" class="py-name" href="#" onclick="return doclink('link-17', '_urlsafe_b64decode', 'link-17');">_urlsafe_b64decode</a></tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
267<a name="L196"></a><tt class="py-lineno">196</tt> <tt class="py-line"> </tt>
268<a name="L197"></a><tt class="py-lineno">197</tt> <tt class="py-line"> <tt class="py-comment"># Parse token.</tt> </tt>
269<a name="L198"></a><tt class="py-lineno">198</tt> <tt class="py-line"> <tt class="py-name">json_body</tt> <tt class="py-op">=</tt> <tt id="link-18" class="py-name"><a title="oauth2client.client._urlsafe_b64decode
270oauth2client.crypt._urlsafe_b64decode" class="py-name" href="#" onclick="return doclink('link-18', '_urlsafe_b64decode', 'link-17');">_urlsafe_b64decode</a></tt><tt class="py-op">(</tt><tt class="py-name">segments</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
271<a name="L199"></a><tt class="py-lineno">199</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
272<a name="L200"></a><tt class="py-lineno">200</tt> <tt class="py-line"> <tt class="py-name">parsed</tt> <tt class="py-op">=</tt> <tt class="py-name">simplejson</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name" targets="Function oauth2client.clientsecrets.loads()=oauth2client.clientsecrets-module.html#loads"><a title="oauth2client.clientsecrets.loads" class="py-name" href="#" onclick="return doclink('link-19', 'loads', 'link-19');">loads</a></tt><tt class="py-op">(</tt><tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
273<a name="L201"></a><tt class="py-lineno">201</tt> <tt class="py-line"> <tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
274<a name="L202"></a><tt class="py-lineno">202</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-20" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-20', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'Can\'t parse token: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
275<a name="L203"></a><tt class="py-lineno">203</tt> <tt class="py-line"> </tt>
276<a name="L204"></a><tt class="py-lineno">204</tt> <tt class="py-line"> <tt class="py-comment"># Check signature.</tt> </tt>
277<a name="L205"></a><tt class="py-lineno">205</tt> <tt class="py-line"> <tt class="py-name">verified</tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
278<a name="L206"></a><tt class="py-lineno">206</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-op">(</tt><tt class="py-name">keyname</tt><tt class="py-op">,</tt> <tt class="py-name">pem</tt><tt class="py-op">)</tt> <tt class="py-keyword">in</tt> <tt class="py-name">certs</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
279<a name="L207"></a><tt class="py-lineno">207</tt> <tt class="py-line"> <tt class="py-name">verifier</tt> <tt class="py-op">=</tt> <tt id="link-21" class="py-name"><a title="oauth2client.crypt.Verifier" class="py-name" href="#" onclick="return doclink('link-21', 'Verifier', 'link-6');">Verifier</a></tt><tt class="py-op">.</tt><tt id="link-22" class="py-name" targets="Static Method oauth2client.crypt.Signer.from_string()=oauth2client.crypt.Signer-class.html#from_string,Static Method oauth2client.crypt.Verifier.from_string()=oauth2client.crypt.Verifier-class.html#from_string"><a title="oauth2client.crypt.Signer.from_string
280oauth2client.crypt.Verifier.from_string" class="py-name" href="#" onclick="return doclink('link-22', 'from_string', 'link-22');">from_string</a></tt><tt class="py-op">(</tt><tt class="py-name">pem</tt><tt class="py-op">,</tt> <tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
281<a name="L208"></a><tt class="py-lineno">208</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-name">verifier</tt><tt class="py-op">.</tt><tt id="link-23" class="py-name"><a title="oauth2client.crypt.Verifier.verify" class="py-name" href="#" onclick="return doclink('link-23', 'verify', 'link-5');">verify</a></tt><tt class="py-op">(</tt><tt class="py-name">signed</tt><tt class="py-op">,</tt> <tt class="py-name">signature</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
282<a name="L209"></a><tt class="py-lineno">209</tt> <tt class="py-line"> <tt class="py-name">verified</tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
283<a name="L210"></a><tt class="py-lineno">210</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
284<a name="L211"></a><tt class="py-lineno">211</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">verified</tt><tt class="py-op">:</tt> </tt>
285<a name="L212"></a><tt class="py-lineno">212</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-24" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-24', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'Invalid token signature: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">jwt</tt><tt class="py-op">)</tt> </tt>
286<a name="L213"></a><tt class="py-lineno">213</tt> <tt class="py-line"> </tt>
287<a name="L214"></a><tt class="py-lineno">214</tt> <tt class="py-line"> <tt class="py-comment"># Check creation timestamp.</tt> </tt>
Joe Gregorio1b425aa2012-08-24 12:04:34 -0400288<a name="L215"></a><tt class="py-lineno">215</tt> <tt class="py-line"> <tt class="py-name">iat</tt> <tt class="py-op">=</tt> <tt class="py-name">parsed</tt><tt class="py-op">.</tt><tt id="link-25" class="py-name" targets="Method apiclient.schema.Schemas.get()=apiclient.schema.Schemas-class.html#get,Method oauth2client.client.MemoryCache.get()=oauth2client.client.MemoryCache-class.html#get,Method oauth2client.client.Storage.get()=oauth2client.client.Storage-class.html#get"><a title="apiclient.schema.Schemas.get
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400289oauth2client.client.MemoryCache.get
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400290oauth2client.client.Storage.get" class="py-name" href="#" onclick="return doclink('link-25', 'get', 'link-25');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'iat'</tt><tt class="py-op">)</tt> </tt>
291<a name="L216"></a><tt class="py-lineno">216</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">iat</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
292<a name="L217"></a><tt class="py-lineno">217</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-26" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-26', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'No iat field in token: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
293<a name="L218"></a><tt class="py-lineno">218</tt> <tt class="py-line"> <tt class="py-name">earliest</tt> <tt class="py-op">=</tt> <tt class="py-name">iat</tt> <tt class="py-op">-</tt> <tt id="link-27" class="py-name"><a title="oauth2client.crypt.CLOCK_SKEW_SECS" class="py-name" href="#" onclick="return doclink('link-27', 'CLOCK_SKEW_SECS', 'link-2');">CLOCK_SKEW_SECS</a></tt> </tt>
294<a name="L219"></a><tt class="py-lineno">219</tt> <tt class="py-line"> </tt>
295<a name="L220"></a><tt class="py-lineno">220</tt> <tt class="py-line"> <tt class="py-comment"># Check expiration timestamp.</tt> </tt>
296<a name="L221"></a><tt class="py-lineno">221</tt> <tt class="py-line"> <tt class="py-name">now</tt> <tt class="py-op">=</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">time</tt><tt class="py-op">.</tt><tt class="py-name">time</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
297<a name="L222"></a><tt class="py-lineno">222</tt> <tt class="py-line"> <tt class="py-name">exp</tt> <tt class="py-op">=</tt> <tt class="py-name">parsed</tt><tt class="py-op">.</tt><tt id="link-28" class="py-name"><a title="apiclient.schema.Schemas.get
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400298oauth2client.client.MemoryCache.get
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400299oauth2client.client.Storage.get" class="py-name" href="#" onclick="return doclink('link-28', 'get', 'link-25');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'exp'</tt><tt class="py-op">)</tt> </tt>
300<a name="L223"></a><tt class="py-lineno">223</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">exp</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
301<a name="L224"></a><tt class="py-lineno">224</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-29" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-29', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'No exp field in token: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
302<a name="L225"></a><tt class="py-lineno">225</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">exp</tt> <tt class="py-op">&gt;=</tt> <tt class="py-name">now</tt> <tt class="py-op">+</tt> <tt id="link-30" class="py-name"><a title="oauth2client.client.SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS
303oauth2client.crypt.MAX_TOKEN_LIFETIME_SECS" class="py-name" href="#" onclick="return doclink('link-30', 'MAX_TOKEN_LIFETIME_SECS', 'link-4');">MAX_TOKEN_LIFETIME_SECS</a></tt><tt class="py-op">:</tt> </tt>
304<a name="L226"></a><tt class="py-lineno">226</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-31" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-31', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt> </tt>
305<a name="L227"></a><tt class="py-lineno">227</tt> <tt class="py-line"> <tt class="py-string">'exp field too far in future: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
306<a name="L228"></a><tt class="py-lineno">228</tt> <tt class="py-line"> <tt class="py-name">latest</tt> <tt class="py-op">=</tt> <tt class="py-name">exp</tt> <tt class="py-op">+</tt> <tt id="link-32" class="py-name"><a title="oauth2client.crypt.CLOCK_SKEW_SECS" class="py-name" href="#" onclick="return doclink('link-32', 'CLOCK_SKEW_SECS', 'link-2');">CLOCK_SKEW_SECS</a></tt> </tt>
307<a name="L229"></a><tt class="py-lineno">229</tt> <tt class="py-line"> </tt>
308<a name="L230"></a><tt class="py-lineno">230</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">now</tt> <tt class="py-op">&lt;</tt> <tt class="py-name">earliest</tt><tt class="py-op">:</tt> </tt>
309<a name="L231"></a><tt class="py-lineno">231</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-33" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-33', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'Token used too early, %d &lt; %d: %s'</tt> <tt class="py-op">%</tt> </tt>
310<a name="L232"></a><tt class="py-lineno">232</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt class="py-name">now</tt><tt class="py-op">,</tt> <tt class="py-name">earliest</tt><tt class="py-op">,</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
311<a name="L233"></a><tt class="py-lineno">233</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">now</tt> <tt class="py-op">&gt;</tt> <tt class="py-name">latest</tt><tt class="py-op">:</tt> </tt>
312<a name="L234"></a><tt class="py-lineno">234</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-34" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-34', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'Token used too late, %d &gt; %d: %s'</tt> <tt class="py-op">%</tt> </tt>
313<a name="L235"></a><tt class="py-lineno">235</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt class="py-name">now</tt><tt class="py-op">,</tt> <tt class="py-name">latest</tt><tt class="py-op">,</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
314<a name="L236"></a><tt class="py-lineno">236</tt> <tt class="py-line"> </tt>
315<a name="L237"></a><tt class="py-lineno">237</tt> <tt class="py-line"> <tt class="py-comment"># Check audience.</tt> </tt>
316<a name="L238"></a><tt class="py-lineno">238</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">audience</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
317<a name="L239"></a><tt class="py-lineno">239</tt> <tt class="py-line"> <tt class="py-name">aud</tt> <tt class="py-op">=</tt> <tt class="py-name">parsed</tt><tt class="py-op">.</tt><tt id="link-35" class="py-name"><a title="apiclient.schema.Schemas.get
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400318oauth2client.client.MemoryCache.get
Joe Gregorioe7a0c472012-07-12 11:46:04 -0400319oauth2client.client.Storage.get" class="py-name" href="#" onclick="return doclink('link-35', 'get', 'link-25');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'aud'</tt><tt class="py-op">)</tt> </tt>
320<a name="L240"></a><tt class="py-lineno">240</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">aud</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
321<a name="L241"></a><tt class="py-lineno">241</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-36" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-36', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'No aud field in token: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt> </tt>
322<a name="L242"></a><tt class="py-lineno">242</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">aud</tt> <tt class="py-op">!=</tt> <tt class="py-name">audience</tt><tt class="py-op">:</tt> </tt>
323<a name="L243"></a><tt class="py-lineno">243</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-37" class="py-name"><a title="oauth2client.crypt.AppIdentityError" class="py-name" href="#" onclick="return doclink('link-37', 'AppIdentityError', 'link-16');">AppIdentityError</a></tt><tt class="py-op">(</tt><tt class="py-string">'Wrong recipient, %s != %s: %s'</tt> <tt class="py-op">%</tt> </tt>
324<a name="L244"></a><tt class="py-lineno">244</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt class="py-name">aud</tt><tt class="py-op">,</tt> <tt class="py-name">audience</tt><tt class="py-op">,</tt> <tt class="py-name">json_body</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
325<a name="L245"></a><tt class="py-lineno">245</tt> <tt class="py-line"> </tt>
326<a name="L246"></a><tt class="py-lineno">246</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">parsed</tt> </tt>
327</div><a name="L247"></a><tt class="py-lineno">247</tt> <tt class="py-line"> </tt><script type="text/javascript">
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400328<!--
329expandto(location.href);
330// -->
331</script>
332</pre>
333<br />
334<!-- ==================== NAVIGATION BAR ==================== -->
335<table class="navbar" border="0" width="100%" cellpadding="0"
336 bgcolor="#a0c0ff" cellspacing="0">
337 <tr valign="middle">
338
339 <!-- Tree link -->
340 <th>&nbsp;&nbsp;&nbsp;<a
341 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
342
343 <!-- Index link -->
344 <th>&nbsp;&nbsp;&nbsp;<a
345 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
346
347 <!-- Help link -->
348 <th>&nbsp;&nbsp;&nbsp;<a
349 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
350
351 <th class="navbar" width="100%"></th>
352 </tr>
353</table>
354<table border="0" cellpadding="0" cellspacing="0" width="100%%">
355 <tr>
356 <td align="left" class="footer">
Joe Gregorio7578da52012-11-01 14:20:00 -0400357 Generated by Epydoc 3.0.1 on Tue Oct 30 14:36:22 2012
Joe Gregorio5dc0f5c2012-06-05 13:34:31 -0400358 </td>
359 <td align="right" class="footer">
360 <a target="mainFrame" href="http://epydoc.sourceforge.net"
361 >http://epydoc.sourceforge.net</a>
362 </td>
363 </tr>
364</table>
365
366<script type="text/javascript">
367 <!--
368 // Private objects are initially displayed (because if
369 // javascript is turned off then we want them to be
370 // visible); but by default, we want to hide them. So hide
371 // them unless we have a cookie that says to show them.
372 checkCookie();
373 // -->
374</script>
375</body>
376</html>