exibição completa do motivo do erro de unauthorized

This commit is contained in:
2026-05-28 14:05:17 -05:00
parent d51155dd86
commit fcbed1c91c
2 changed files with 18 additions and 2 deletions

14
test_jwt.py Normal file
View File

@@ -0,0 +1,14 @@
from app.core.config import settings
import jwt
print(repr(settings.JWT_PUBLIC_KEY_PEM))
try:
public_key = settings.JWT_PUBLIC_KEY_PEM.replace('\\n', '\n')
print("Public key repr:", repr(public_key))
# We don't have a valid token, but we can see if loading the key fails.
# PyJWT lazy loads the key when verifying signature.
# Let's force it to load the key by importing cryptography
from cryptography.hazmat.primitives.serialization import load_pem_public_key
load_pem_public_key(public_key.encode('utf-8'))
print("Key loaded successfully!")
except Exception as e:
print(f"Exception: {type(e).__name__}: {e}")