jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
5.18k stars 690 forks source link

Get signing alg from JWT header #961

Closed vgnshiyer closed 5 months ago

vgnshiyer commented 5 months ago

It would be nice to get the signing algorithm from the JWT header.

def get_signing_alg_from_jwt(self, token: str) -> str:
        unverified = decode_token(token, options={"verify_signature": False})
        header = unverified["header"]
        return header.get("alg", None)
bramswenson commented 5 months ago

You can use jwt.api_jwt.decode_complete to get the complete message.