mirror of
https://github.com/emqx/neuron.git
synced 2026-10-27 12:28:44 +08:00
fix(jwt): add jwt encode for test
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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}")
|
||||
Reference in New Issue
Block a user