title: Python and Flask for authentication with Amazon Cognito
body: <p>Here's the end goal: to write a Flask app that supports login/authentication using Amazon Cognito User Pools. Both frameworks are fairly new to me.</p>
  
  <p>I used warrant serverless authentication to get a JWT access token from Cognito. However, I'm not sure how or what I need to verify the token as valid.
  I've read through a few answers on this site as well as the following links:</p>
  
  <p><a href="https://aws.amazon.com/premiumsupport/knowledge-center/decode-verify-cognito-json-token/" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/decode-verify-cognito-json-token/</a>
  <a href="https://aws.amazon.com/blogs/mobile/integrating-amazon-cognito-user-pools-with-api-gateway/" rel="nofollow noreferrer">https://aws.amazon.com/blogs/mobile/integrating-amazon-cognito-user-pools-with-api-gateway/</a></p>
  
  <p>The first link suggests: </p>
  
  <blockquote>
    <p>To verify the signature of an Amazon Cognito JWT, first search for the key with a key ID that matches the key ID of the JWT. Then, use libraries to decode the token and verify the signature.</p>
  </blockquote>
  
  <p>I retrieved a JWK for the public key from the provided link, but I'm not sure how to use it. What libraries could I use to decode the token, keeping in mind I am working in a Python environment? I looked at flask-jwt-extended, but the provided classes and methods don't seem to solve my exact problem. Should I override classes and functions in flask-jwt-extended to get the desired effect?</p>
  
  <p>Or if I'm approaching this problem in the wrong way, any pointers or suggestions?</p>