Skip to content
Advertisement

Working outside of application context Flask JWT decorator issue

I am fairly new to Flask applications. While my application works for all the endpoints as expected when I tried to add jwt authorization I encountered this issue. I have tried this solution app.app_context().push() based on some other questions that have been posted.

Any help would be greatly appreciated. I would also like to use the decorator in multiple apis, should I include the token_required function in each one, or best practise would be to be imported?

Error:

JavaScript

My application structure:

main.py

JavaScript

app.py

JavaScript

usersapi.py

JavaScript

Advertisement

Answer

return decorated not return decorated() in token_required. Otherwise, you’ll be calling the wrapped function whenever you define a decorated function.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement