How do I sign a JWT using ES256?

1k views Asked by At

I am trying to sign using pyjwt

key = jwk.JWK.from_pem(pkey_contents)
token = jwt.JWT(header={"alg": "ES256"},
                     claims=Token.serialize())
token.make_encrypted_token(key)

and I am getting this error

app_1         |   File "/usr/local/lib/python3.6/site-packages/jwcrypto/jwe.py", line 122, in _jwa_keymgmt
app_1         |     raise InvalidJWEOperation('Algorithm not allowed')
app_1         | jwcrypto.common.InvalidJWEOperation: Algorithm not allowed
1

There are 1 answers

0
wonton On

Replace make_encrypted_token with make_signed_token

Make encrypted_token encrypts the end token whereas ES256 is used to sign the token.