'Flask JWT with RESTful api

How to use JWT with RESTful?

It works

@app.route('/test_route')
@jwt_required()
def protected():
    return '%s' % current_identity

But what to do in this case?

api.add_resource(testApi, '/test_api')

I cannot find this case in the Flask-JWT documentation



Solution 1:[1]

You can try out something like this:

class TestApi(Resource):
     @jwt_required()
     def get(self):
         return '%s' % current_identity

later use this: api.add_resource(TestApi, '/test_api')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RJB