Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.0 kB
3
Indexable
Never
import jwt
from jwt import PyJWKClient

cognito_user_pool_id = "us-east-1_f1oN3uxu6"
cognito_client_id = "mi6m1p1j3c7q6hdfiapmar0cb"

jwt_url = f"https://cognito-idp.us-east-1.amazonaws.com/{cognito_user_pool_id}/.well-known/jwks.json"
    
def verify_jwt_token(token) :
    client = PyJWKClient(jwt_url)
    pub_key = client.get_signing_key_from_jwt(token).key
    validation = jwt.decode(token, pub_key, audience = cognito_client_id, algorithms = ["RS256"], options = {"verify_signature": True, "verify_exp": True})
    
    print(validation)


cookie = "eyJraWQiOiJzOVltc0NcL0JJbjRCVG1pYWF4ZnZRMXFibFhwQ3RXUFM5MEt2MmtuVkY0QT0iLCJhbGciOiJSUzI1NiJ9.eyJhdF9oYXNoIjoiV1g2RExzaU5JeWxHTDIyS3dOTUF2USIsInN1YiI6ImI0OTg4NDU4LTgwZjEtNzA4NC04MjA0LTU2OGJjNzZmNzE3MSIsImNvZ25pdG86Z3JvdXBzIjpbInVzLWVhc3QtMV9mMW9OM3V4dTZfR29vZ2xlIl0sImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfZjFvTjN1eHU2IiwiY29nbml0bzp1c2VybmFtZSI6Ikdvb2dsZV8xMDY2MjY2NTYwOTI1MTMwNzM1NTAiLCJnaXZlbl9uYW1lIjoiUXVhbmciLCJvcmlnaW5fanRpIjoiN2Q0OTk5MDAtNjBlZi00OTIzLWE0ZjQtNDhhM2M3MmZhY2UxIiwiYXVkIjoibWk2bTFwMWozYzdxNmhkZmlhcG1hcjBjYiIsImlkZW50aXRpZXMiOlt7InVzZXJJZCI6IjEwNjYyNjY1NjA5MjUxMzA3MzU1MCIsInByb3ZpZGVyTmFtZSI6Ikdvb2dsZSIsInByb3ZpZGVyVHlwZSI6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