title: How to create a JWT using ES256 in GAE
body: <p>I am working on a Google App Engine solution that needs to integrate with an API where the authentication is being done with JWT. The encryption algorithm to be used is ES256, but every time I try to call the <code>jwt.encode()</code> method with ES256, the following error gets thrown:</p>
  
  <p><code>ImportError: No module named cryptography.hazmat.bindings._constant_time</code></p>
  
  <p>This is happening because cryptography.io is not supported on App Engine (standard env) as it uses CFFI (C Foreign Function Interface).</p>
  
  <p>Are there any other recommended approaches to create this JWT from my Python App Engine app and using ES256?</p>
  
  <p>Here's the simplified code:</p>
  
  <pre><code>import jwt
  
  keystring = """-----BEGIN PRIVATE KEY-----
  SECRET
  -----END PRIVATE KEY-----"""
  
  HEADERS = {'alg': 'ES256', 'kid': '1234SECRET', 'typ': 'JWT'}
  PAYLOAD = {
      'iss': 'secret-secret-secret',
      'exp': time.time() + 20 * 60,
      'aud': 'audience'
  }
  
  key = jwt.encode(PAYLOAD, keystring, algorithm='ES256', headers=HEADERS)
  </code></pre>
  
  <p>Thanks in advance.</p>