0

On my Flask-restplus swagger documentation I have defined an endpoint that gets me list of public ip address, I have learned that I can define a model

resource_fields = api.model('Resource', {
    'name': fields.String,
})

but I have also learned that I can use parser:

parser = api.parser()
parser.add_argument('param', type=int, help='Some param', location='form')
parser.add_argument('in_files', type=FileStorage, location='files')


@api.route('/with-parser/', endpoint='with-parser')
class WithParserResource(restplus.Resource):
    @api.expect(parser)
    def get(self):
        return {}

which one should I use, to pass JWT token ? as what I want to pass is a header so in curl that would be curl -X GET -H "AUTHORIZATION: JWT some_xyz_token" http://url/api/doc

Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
  • You should probably use [`Authorization: Bearer xyz`](https://stackoverflow.com/a/33281233/113116), not `Authorization: JWT xyz`. Related: [How can I represent 'Authorization: Bearer ' in a Swagger Spec (swagger.json)](https://stackoverflow.com/q/32910065/113116) – Helen Feb 24 '18 at 07:32
  • Yes I came across the post just a while back .. @Helen I already tried that, and it didn't worked. when I hit the "Try Out" in swagger UI, it hangs forever , showing the dot based progress bar... and nothing in terminal. – Ciasto piekarz Feb 24 '18 at 07:51
  • I have also tried this approach: http://flask-restplus.readthedocs.io/en/latest/swagger.html?highlight=headers#headers – Ciasto piekarz Feb 24 '18 at 08:09
  • if I run curl in terminal `-H "Authorization: JWT"` works but `-H "Authorization: Bearer"` does not work. although I had a look at documentation it should work – Ciasto piekarz Feb 24 '18 at 09:11

0 Answers0