[Answered ]-Access the values ​of this result, obtained from an api

1👍

Here’s how you can check whether your token is expired or not using pyjwt module for example:

import jwt
import time

key = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjVMcDByZ0xrNmJYS3RHZURzSmhMeS1xakFobyIsImtpZCI6IjVMcDByZ0xrNmJYS3RHZURzSmhMeS1xakFobyJ9.eyJjbGllbnRfaWQiOiJJbnRlcnB1YmxpY2EiLCJzY29wZSI6IkludGVycHVibGljYSIsInN1YiI6IjkzNDkyZmU2LWU1NTEtNDMwNy04ODdkLTQwODIxYmZhZmE2ZSIsImFtciI6WyJwYXNzd29yZCJdLCJhdXRoX3RpbWUiOjE2MTcyNzQyNTcsImlkcCI6Imlkc3J2IiwicHJlZmVycmVkX3VzZXJuYW1lIjoiQ29ycmFsZXMiLCJlbWFpbCI6Im5vbWFpbEBub21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOiJ0cnVlIiwicGhvbmVfbnVtYmVyIjoiNDQ0NDQ0NDQ0IiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjoidHJ1ZSIsIlVzdWFyaW8iOiI1MyIsIlNlcnZpZG9yIjoiMyIsIkRvbWluaW8iOiIyNyIsIkVudGlkYWQiOiI1MyIsInJvbGUiOlsiRG9tYWluIiwiSW50ZXJwdWJsaWNhIiwiUGFkcm9uIl0sImp0aSI6IjE5YTFlM2UzMWI3NDg5ZGM1ZjA2NTJhNjJlYTAzMGMyIiwiaXNzIjoiaHR0cHM6Ly9wcmUtaW50ZXJwdWJsaWNhYXV0aG9yaXphdGlvbi5pbnRlcnB1YmxpY2EuZXMvaWRlbnRpdHkiLCJhdWQiOiJodHRwczovL3ByZS1pbnRlcnB1YmxpY2FhdXRob3JpemF0aW9uLmludGVycHVibGljYS5lcy9pZGVudGl0eS9yZXNvdXJjZXMiLCJleHAiOjE2MTcyNzc4NTgsIm5iZiI6MTYxNzI3NDI1OH0.CbYFfMNHfaqjmtdDx6Bb3sfrzMBbWmi9p1-4xsYLQxOmigupwZqnHHopy5Ltu3mwWftNwvPj0Lx1bH5m1kI0wG0Y_zWqQ3N7UacZDtApfaoNpwOjygPWcZsHj83V2xdYKSPGBFjaDng_9TECBz4ANOlmbh7c0pklLu-nA_Od9E_wa2znq8CGv4sxIC4ViTeoEclMAq--sP2j1FNxZiFinq7dG32QV7zzR_1JJjVjtzK4eAT4CViZFhedsswn9OEn6wctJtmnDkRBnQioHSvz2wM5J-tngVS6tn_o1PUwVtykBc_0_TTfowiJkAkEmSQJKobAQPIgVvPrH4JsNeahGw'
decoded = jwt.decode(key, options={"verify_signature": False})
exp_timestamp = decoded['exp']

print(f'expires: {time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime(exp_timestamp))}')
print(f'expired: {exp_timestamp < time.time()}')
expires: Thu, 01 Apr 2021 11:50:58
expired: True

Not sure if it answers your question though 🙂

👤absoup

Leave a comment