cookiecutter-flask-restful icon indicating copy to clipboard operation
cookiecutter-flask-restful copied to clipboard

ImportError: cannot import name 'jwt_refresh_token_required' from 'flask_jwt_extended'

Open harshrpatel opened this issue 4 years ago • 8 comments
trafficstars

Having this error as soon as I cloned the project and tried installation steps, can someone help me set this up?

here's my pip freeze :

alembic==1.5.4 aniso8601==8.1.1 apispec==4.3.0 apispec-webframeworks==0.5.2 appdirs==1.4.4 arrow==0.17.0 binaryornot==0.4.4 certifi==2020.12.5 chardet==4.0.0 click==7.1.2 cookiecutter==1.7.2 distlib==0.3.1 filelock==3.0.12 Flask==1.1.2 Flask-JWT-Extended==4.0.2 flask-marshmallow==0.14.0 Flask-Migrate==2.6.0 Flask-RESTful==0.3.8 Flask-SQLAlchemy==2.4.4 gunicorn==20.0.4 idna==2.10 itsdangerous==1.1.0 Jinja2==2.11.3 jinja2-time==0.2.0 Mako==1.1.4 MarkupSafe==1.1.1 marshmallow==3.10.0 marshmallow-sqlalchemy==0.24.2 packaging==20.9 passlib==1.7.4 pluggy==0.13.1 poyo==0.5.0 py==1.10.0 PyJWT==2.0.1 pyparsing==2.4.7 python-dateutil==2.8.1 python-dotenv==0.15.0 python-editor==1.0.4 python-slugify==4.0.1 pytz==2021.1 PyYAML==5.4.1 requests==2.25.1 six==1.15.0 SQLAlchemy==1.3.23 text-unidecode==1.3 toml==0.10.2 tox==3.22.0 urllib3==1.26.3 virtualenv==20.4.2 Werkzeug==1.0.1

harshrpatel avatar Feb 16 '21 09:02 harshrpatel

Looks like there were breaking changes for flask-jwt-extended 4.0.2.

auth/views.py calls some functions that no longer exist, were deprecated, or were replaced in v4 of flask-jwt-extended.

I was able to fix it by updating the imports and changing some calls: https://gist.github.com/bitjockey42/4921deadd3f57ec248796b83495baf54

Hope that helps.

bitjockey42 avatar Feb 17 '21 04:02 bitjockey42

Hi @bitjockey42 , I saw your fix, but im getting the following error when calling a blueprint endpoint, F.E: /api/v1/users It result into a 500 with the following log: TypeError: wrapper() missing 1 required positional argument: 'fn' Did you already fixed this error by your own, or it only happen to me ? thx!

alembic==1.5.5
aniso8601==9.0.0
apispec==4.3.0
apispec-webframeworks==0.5.2
appdirs==1.4.4
click==7.1.2
distlib==0.3.1
filelock==3.0.12
Flask==1.1.2
Flask-JWT-Extended==4.0.2
flask-marshmallow==0.14.0
Flask-Migrate==2.7.0
Flask-RESTful==0.3.8
Flask-SQLAlchemy==2.4.4
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.3
Mako==1.1.4
MarkupSafe==1.1.1
marshmallow==3.10.0
marshmallow-sqlalchemy==0.24.2
packaging==20.9
passlib==1.7.4
pluggy==0.13.1
py==1.10.0
PyJWT==2.0.1
pyparsing==2.4.7
python-dateutil==2.8.1
python-dotenv==0.15.0
python-editor==1.0.4
pytz==2021.1
PyYAML==5.4.1
six==1.15.0
SQLAlchemy==1.3.23
toml==0.10.2
tox==3.22.0
virtualenv==20.4.2
Werkzeug==1.0.1

hpardora avatar Feb 27 '21 15:02 hpardora

Hello @hpardora and @bitjockey42 and sorry for taking so long to answer.

As @bitjockey42 pointed out, those issues are related to breaking changes introduced in flask-jwt-extended. I'm currently working on a fix and I will do my best to release it ASAP.

@hpardora if that can help you, the issue you encounter right now is linked to those API changes and you'll need to replace

@jwt_required

with

@jwt_required()

karec avatar Mar 01 '21 12:03 karec

@hpardora @bitjockey42 issue should be solved with commit f1e9a29, build is passing now

karec avatar Mar 01 '21 14:03 karec

@karec thx! i will try later.

hpardora avatar Mar 01 '21 14:03 hpardora

@karec Tried the template again and your fix in that commit worked! Thank you

bitjockey42 avatar Mar 14 '21 19:03 bitjockey42

@bitjockey42 thanks for the feedback, I'll close this issue, don't hesitate to re-open it if you still have issues with the flask_jwt_extended upgrade

karec avatar Mar 15 '21 09:03 karec

Hello @alexanderdamiani

This is due to a breaking change in flask_jwt_extended itself, see here for more details.

In this cookiecutter I've upgraded imports to match those breaking changes, do you still have issues with the cookiecutter ? if yes could you point me to the file that cause error ?

karec avatar Dec 01 '21 09:12 karec