简体   繁体   中英

How do I sign a JWT using ES256?

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

Replace make_encrypted_token with make_signed_token

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM