【问题标题】:Alexa skill acount linkingAlexa 技能帐号关联
【发布时间】: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 中对用户进行身份验证?

【问题讨论】:

    标签: python flask jwt alexa


    【解决方案1】:

    您需要在亚马逊的注册用户和您的系统之间进行账户链接。这是一个相当大的话题。你可以在这里阅读更多:https://developer.amazon.com/en-US/docs/alexa/account-linking/understand-account-linking.html

    【讨论】:

    • 第二。设置帐户链接后,身份验证令牌将包含在技能执行的上下文中,允许您访问它并将其传递给技能内的任何后续 REST 调用。这是一个不错的系统。
    猜你喜欢
    • 2017-07-13
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    相关资源
    最近更新 更多