Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JWT dont accept Authorization with Bearer

I was trying to use swagger with flask as docs api

the problem i get now is that when the request sended use This header

Authorization: Bearer <jwt_token>

I get this error :

{
  "description": "Unsupported authorization type",
  "error": "Invalid JWT header",
  "status_code": 401
}

when i use

Authorization: JWT <jwt_token>

All work great , so any good implementation to fix this with swagger and make it use JWT and not Bearer

like image 990
Dcoder Avatar asked Oct 29 '25 09:10

Dcoder


2 Answers

Had the same issue, the solution is to use the headers as such

key: Authorization

value: jwt {token}

as simple as that.

like image 166
Adi Avatar answered Oct 31 '25 10:10

Adi


I'm not sure about changing the swagger stuff, but if you are using flask-jwt-extended you can change the rest of your flask application to also use JWT instead of Bearer to keep everything consistent. See the JWT_HEADER_TYPE option here: http://flask-jwt-extended.readthedocs.io/en/latest/options.html#header-options

like image 25
vimalloc Avatar answered Oct 31 '25 12:10

vimalloc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!