【发布时间】:2020-04-01 11:52:30
【问题描述】:
我有一个使用 Python Flask 定义的 REST API,我想通过使用 Alexa Skill 向该 API 发出 http 请求。
@app.route('/auth', methods=["POST"])
def auth_user():
data = request.get_json()
users = db.users
logged_user = users.find_one({'username' : data["username"]})
if logged_user is not None and bcrypt.check_password_hash(logged_user['password'], data['password']):
access_token = create_access_token(identity=data["username"])
return jsonify({'logged_user':logged_user,'access_token':access_token})
else:
return "Invalid password or username"
正如您在上面看到的,我检查凭据是否正确,然后在响应中发送 access_token。然后,remaning 端点需要 jwt 来执行请求。
如何使用 Alexa 技能做到这一点?如何首先在 API 中对用户进行身份验证?
【问题讨论】: