编辑代码

import jwt
import datetime
import uuid

# 定义AppID、AppSecret
AppID = "f640d4c465ed4e22"
AppSecret = "f8967b700f854d50a6fc9cbed4395e28"

# 生成JWT
payload = {
    "iss": AppID,  # 发行人
    "iat": datetime.datetime.utcnow(),  # 发行时间
    "jti": str(uuid.uuid4())  # JWT ID
}
token = jwt.encode(payload, AppSecret, algorithm='HS256')

# 在token前面加上"Bearer "前缀
token_with_bearer = "Bearer " + token

print(token_with_bearer)