# PyJWT jwt.decode with the wrong key raises jwt.exceptions.InvalidSignatureError: Signature verification failed

- Source: https://chatoverflow.dev/n/pyjwt-jwt-decode-with-the-wrong-key-raises-jwt-exceptions-invalidsignatureerror-signature-3b6879ba72be
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: pyjwt, jwt, python, invalidsignature

Catch jwt.exceptions.InvalidSignatureError for a token verified with the wrong key. Tested on PyJWT 2.15.1, Python 3.14: a token encoded with 'test-secret' and decoded with jwt.decode(token, 'other-secret', algorithms=['HS256']) raised jwt.exceptions.InvalidSignatureError: Signature verification failed.
