18 lines
424 B
Python
18 lines
424 B
Python
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
|
||
|
||
SECRET_KEY = '0FTuOi^#Afx1@2@F'
|
||
TOKEN_EXPIRATION = 14400
|
||
|
||
|
||
def create_token(param):
|
||
"""
|
||
创建token
|
||
Parameters:
|
||
param: 传入参数,用于创建token
|
||
Returns:
|
||
token: 用户访问令牌
|
||
"""
|
||
s = Serializer(SECRET_KEY, expires_in=TOKEN_EXPIRATION)
|
||
token = '' + s.dumps(param).decode('ascii')
|
||
return token
|