Vukasin
Vukasin

Reputation: 561

flask security auth_token_required - token authentication

I've successfully implemented token auth and protect my rest web service method with it - this is great approach.

Now I have trouble to access user data from token - like ID - in order to manipulate with it in accessed (protected) rest service method.

Any idea ?

Upvotes: 0

Views: 1582

Answers (1)

Matt W
Matt W

Reputation: 6108

You need to import the current_user which will reflect the currently authenticated user for the current request.

from flask_security import current_user, auth_token_required

@app.route('/')
@auth_token_required
def view():
    print current_user.id

Upvotes: 3

Related Questions