jpadilla / pyjwt

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

Get signing alg from JWT header #961

Closed vgnshiyer closed 3 months ago

vgnshiyer commented 3 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 3 months ago

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