0
0

More than 3 years have passed since last update.

Python3: Zoom の token を取得

Last updated at Posted at 2021-03-14

参考ページ
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 = '********************************'
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0