18 Star 222 Fork 67

EMQX/neuron

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
jwt_encode.py 477 Bytes
一键复制 编辑 原始数据 按行查看 历史
gaoc 提交于 2024-06-11 15:30 . fix(jwt): add jwt encode for test
import jwt # pip install pyjwt
import time
with open("neuron.key", "r") as f:
private_key = f.read()
current_time = int(time.time())
two_years = 60 * 60 * 24 * 365 * 2
header = {"alg": "RS256", "typ": "JWT"}
payload = {
"aud": "neuron",
"bodyEncode": 0,
"exp": current_time + two_years,
"iat": current_time,
"iss": "neuron",
}
token = jwt.encode(payload, private_key, algorithm="RS256", headers=header).decode(
"utf-8"
)
print(f"Bearer {token}")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/emqx/neuron.git
git@gitee.com:emqx/neuron.git
emqx
neuron
neuron
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385