tfse-app-api-v0.2/user/user_utils.py

18 lines
424 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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