Skip to content

Instantly share code, notes, and snippets.

@themarcelor
Created June 9, 2021 16:26
Show Gist options
  • Select an option

  • Save themarcelor/325d9cb4904a229fe3db243be4c4e2ea to your computer and use it in GitHub Desktop.

Select an option

Save themarcelor/325d9cb4904a229fe3db243be4c4e2ea to your computer and use it in GitHub Desktop.
# Install dependency:
# pip install PyJWT==1.4.0
# How to:
# python debug_api_key.py ~/Downloads/credentials.json
import json
import sys
import base64
import jwt
import time
from pprint import pprint
def main():
if len(sys.argv) == 1:
print('please provide the credentials.json path')
sys.exit(1)
credentials_path = sys.argv[1]
print('reading credentials.json path: {}'.format(credentials_path))
credentials_data = None
with open(credentials_path) as f:
credentials_data = json.load(f)
#print('credentials_data: {}'.format(credentials_data))
decoded_api_key = jwt.decode(credentials_data['api_key'], verify=False)
#print('the api_key: {}'.format(decoded_api_key))
expiry_date = decoded_api_key['exp']
print(time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(expiry_date)))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment