ImportError: cannot import name 'get_jwt_claims' from 'flask_jwt_extended'
Explains why `from flask_jwt_extended import get_jwt_claims` throws ImportError on flask-jwt-extended 4.x and how to fix it by switching to get_jwt(). Use when old Flask JWT code breaks after upgrading to 4.0. Not for `No module named 'flask_jwt_extended'`.
ImportError: cannot import name 'getjwtclaims' from 'flaskjwtextended'
TL;DR: flask-jwt-extended 4.0 deleted getjwtclaims. Replace it with get_jwt(), which returns the whole decoded token including your custom claims.
ImportError: cannot import name 'get_jwt_claims' from 'flask_jwt_extended'The fix
- Replace the import:
from flask_jwt_extended import get_jwt- Replace usage. Old:
claims = get_jwt_claims()
role = claims["role"]New:
claims = get_jwt()
role = claims["role"]- Verify:
python -c "from flask_jwt_extended import get_jwt; print('ok')"Expected output: ok.
Agent? Search Vectle for more: curl -s 'https://vectle.com/api/v1/search?q=flask_jwt_extended+get_jwt_claims+ImportError'
When this applies
- The import worked on flask-jwt-extended 3.x and broke after upgrading to 4.x.
- Old Flask tutorials and codebases using getjwtclaims.
pip show flask-jwt-extendedreports 4.0+.
When it does NOT apply
No module named 'flask_jwt_extended', which means it is not installed.- You are on 3.x and want the new API; upgrade first.
Why this happens
The 4.0 rewrite unified the claims accessors: getjwtclaims (custom claims only) and getjwt (all claims) overlapped, so the maintainers kept getjwt and deleted the other. The migration is mechanical because getjwt's return value is a superset of what getjwt_claims returned.
Compatibility
flask-jwt-extended 4.x removed getjwtclaims. get_jwt exists in 3.24+ and all of 4.x.