vimalloc / flask-jwt-extended

An open source Flask extension that provides JWT support (with batteries included)!
http://flask-jwt-extended.readthedocs.io/en/stable/
MIT License
1.55k stars 240 forks source link

get_jwt_identity return => "msg": "Missing Authorization Header" #302

Closed engmsilva closed 4 years ago

engmsilva commented 4 years ago

I can retrieve the token identity value when sent by the postman header.

However when I use string query is returning the error message:

api/protected?jwt=<access_token>

{
   "msg": "Missing Authorization Header"
}

My recovery code looks like this:

class User_Confirm(Resource):
    @jwt_required
    def get(cls):       
        user_id = get_jwt_identity()
        return print(user_id)

I'm using flask_restful to do routing.

Is there anything else that should be parameterized?

aniso8601==8.0.0
blinker==1.4
Click==7.0
Flask==1.1.1
Flask-Cors==3.0.8
Flask-JWT-Extended==3.24.1
Flask-Mail==0.9.0
Flask-RESTful==0.3.7
Flask-SQLAlchemy==2.4.1
itsdangerous==1.1.0
Jinja2==2.10.3
MarkupSafe==1.1.1
psycopg2-binary==2.8.4
PyJWT==1.7.1
python-dotenv==0.10.3
pytz==2019.3
six==1.13.0
SQLAlchemy==1.3.11
Werkzeug==0.16.0
vimalloc commented 4 years ago

Make sure you set the JWT_TOKEN_LOCATION option accordingly For example, app.config[‘JWT_TOKEN_LOCATION’] = [‘headers’, ‘query_string’]

engmsilva commented 4 years ago

@vimalloc Thanks for the feedback. Below are my settings, but it seems that only token by header is being accepted.

app.config['JWT_TOKEN_LOCATION'] = ['headers', 'query_string']
app.config['JWT_SECRET_KEY'] = os.getenv("JWT_SECRET_KEY")
app.config['JWT_BLACKLIST_ENABLED'] = True
jwt = JWTManager(app)
engmsilva commented 4 years ago

Please disregard the previous answer when adding the settings: app.config['JWT_TOKEN_LOCATION'] = ['headers', 'query_string'] The token for the string query worked.

Thank you @vimalloc

vimalloc commented 4 years ago

Awesome, glad to hear it :+1:

Sangkibet-netsh commented 1 year ago

"msg": "Missing JWT in headers or query_string (Missing Authorization Header; Missing 'jwt' query paramater)" i got this error in the process

mark-baumann commented 1 month ago

"msg": "Missing JWT in headers or query_string (Missing Authorization Header; Missing 'jwt' query paramater)" i got this error in the process

I have the same error