【发布时间】:2019-05-29 07:44:08
【问题描述】:
我已经使用 Flask 为 REST API 服务器设计了 Web 应用程序
为了从前端获取 id 和 key,后端将获取信息并执行一些操作 (仅使用 POST 方法) 卷曲命令
curl -X POST -H "Content-Type:application/json" --data "{/"account_id/":/"100002/", /"access_key/":/"AKIAWDL6TY5M2INS6J7E/"}" https://192.168.172.130:443/account
但是,当我使用如下 curl 命令时:
X POST -H "Content-Type:application/json" --data "{/"account_id/":/"100002/", /"access_key/":/"AKIAWDL6TY5M2INS6J7E/"}" https://192.168.172.130 :443/账户 curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - 提供给函数的令牌无效run.py 中的代码设计
def scan_account(_account_id:str, _access_key:str):
# building connection to db
mySQLDB = mysqlDBConnector()
mySQLDB.dbConnection()
#init record log request
_now_time = datetime.datetime.now()
_request_info_log:str = 'Request of account id:'+str(_account_id)+' With Access Key: '+str(_access_key)+' at: '+str(_now_time)+' direction data: incoming with action type: post request'
mySQLDB.db_log_request_insert(_request_info_log)
# get secret key
_AccountID: int = _account_id
_AccessKey: str = _access_key
_SecretKey: str = mySQLDB.db_get_key(_AccountID,_AccessKey)
# init boto3 session
_aws_session = AWS_Session(_AccessKey, _SecretKey)
_aws_session.get_credentials()
#init running
_worker = Worker()
attrs = (getattr(_worker, name) for name in dir(_worker))
methods = filter(inspect.ismethod, attrs)
for method in methods:
_thread_method = threading.Thread(target=method, args=(_aws_session,))
_thread_method.start()
_thread_method.join()
@app.route("/account/",methods=["POST"])
def account_info():
_account_id = request.json['account_id']
_access_key = request.json['access_key']
#data = {'acount_id': _account_id, 'access_key': _access_key}
scan_account(_account_id,_access_key)
#return jsonify(data)
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0', port='443')
【问题讨论】:
-
你看过这个吗? blog.miguelgrinberg.com/post/… 看起来您缺少步骤。
-
@JavierBuzzi,我还没有,但你能解释一下为什么。谢谢