参考ページ
christophercollins/ZoomToken
Arch Linux で必要なライブラリーをインストール
sudo pacman -S python-pyjwt
gen_tokey.py
#! /usr/bin/python
#
# gen_tokey.py
#
# Mar/14/2021
# ------------------------------------------------------------------
import os
import jwt
import time
import json
from dotenv import load_dotenv
# ------------------------------------------------------------------
def file_write_proc(file_name,str_out):
#
fp_out = open(file_name,mode='w',encoding='utf-8')
fp_out.write(str_out)
fp_out.close()
#
# ------------------------------------------------------------------
dotenv_path = '.env'
load_dotenv(dotenv_path)
API_KEY = os.environ.get("API_KEY")
API_SECRET = os.environ.get("API_SECRET")
expiration = int(time.time()) + 3600
encode = jwt.encode(
{"iss": API_KEY, "exp": expiration},
API_SECRET,
algorithm="HS256",
headers={"typ": "JWT"},
)
token = encode.decode('utf-8')
unit_aa = {}
unit_aa['token'] = token
out_str = json.dumps(unit_aa)
file_out = "token.json"
file_write_proc(file_out,out_str)
# ------------------------------------------------------------------
.env
API_KEY = '*******'
API_SECRET = '********************************'