# 简单的用户名密码登录获取token的方式
import logging
from flask import Flask, request, g, make_response, jsonify
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadSignature, SignatureExpired
# from flask_restful import Api, Resource
app = Flask(__name__)
# 用户名密码方式认证,仅用于登录
basic_auth = HTTPBasicAuth()
# Token方式认证
token_auth = HTTPTokenAuth(scheme="Bearer")
users = [
{'username': 'Tom', 'password': '111111'},
{'username': 'Michael', 'password': '123456'}
]
# 用户登录后的token字典
# tokens={'id1': 'token1', 'id2': 'token2','id3': 'token3'}
tokens = {}
# 定义token加密、过期时间、盐SALT。例如SECRET_KEY=&#