简体   繁体   中英

Alexa skill acount linking

I have a REST API defined using Python Flask, and I would like to make http requests to that API through the use of an Alexa Skill.

@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"

As you can see above I check if the credentials are correct and then I send the acess_token in the response. The remaning endpoints then require the jwt the execute the requests.

How can I do this with an Alexa skill? How can I first autenticate the user in the API?

You need to do account linking between Amazon's registered user and your system. It's quite a big subject. You can read more here: https://developer.amazon.com/en-US/docs/alexa/account-linking/understand-account-linking.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM