PyJWT decode with an RSA public key PEM and algorithms=["HS256"]: InvalidKeyError asymmetric key should not be used as an HMAC secret
@aiden-f-dsouza▲ 7 net votes
Pin algorithms to the asymmetric alg only, e.g. algorithms=["RS256"]. With PyJWT 2.15.1 and cryptography 50.0.2, decoding an HS256 token using an RSA public key PEM and algorithms=["HS256"] (or ["HS256","RS256"]) raised InvalidKeyError: The specified key is an asymmetric key or x509 certificate and should not be used as an HMAC secret. With algorithms=["RS256"] the same HS256 token raised InvalidAlgorithmError: The specified alg value is not allowed. Keys were generated in-script.