We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ES256, i am trying to generate JWT token with following code
ES256
audience = 'https://appleid.apple.com' alg = 'ES256' # Define issue timestamp. issued_at_timestamp = int(dt.datetime.utcnow().timestamp()) # Define expiration timestamp. May not exceed 180 days from issue timestamp. expiration_timestamp = issued_at_timestamp + 86400 * 180 # Define JWT headers. headers = dict() headers['alg'] = alg headers['kid'] = key_id # Define JWT payload. payload = dict() payload['sub'] = client_id payload['aud'] = audience payload['iat'] = issued_at_timestamp payload['exp'] = expiration_timestamp payload['iss'] = team_id with open(private_key_file, 'r') as key_file: key = ''.join(key_file.readlines()) client_secret = jwt.encode( payload=payload, headers=headers, algorithm=alg, key=key )
private key file is .pem with -----BEGIN RSA PRIVATE KEY----- inside
-----BEGIN RSA PRIVATE KEY-----
Expected to generate token. Same code worked 6 months ago.
File "/Users/Alexander_Gorokhov/PycharmProjects/hs-databricks/tasks.py", line 128, in generate_asa_client_secret client_secret = jwt.encode( File "/Users/Alexander_Gorokhov/.local/share/virtualenvs/hs-databricks-35vk8C_U/lib/python3.9/site-packages/jwt/api_jwt.py", line 63, in encode return api_jws.encode(json_payload, key, algorithm, headers, json_encoder) File "/Users/Alexander_Gorokhov/.local/share/virtualenvs/hs-databricks-35vk8C_U/lib/python3.9/site-packages/jwt/api_jws.py", line 114, in encode signature = alg_obj.sign(signing_input, key) File "/Users/Alexander_Gorokhov/.local/share/virtualenvs/hs-databricks-35vk8C_U/lib/python3.9/site-packages/jwt/algorithms.py", line 423, in sign der_sig = key.sign(msg, ec.ECDSA(self.hash_alg())) TypeError: sign() missing 1 required positional argument: 'algorithm'
key is cryptography.hazmat.backends.openssl.rsa._RSAPrivateKey sign_obj is jwt.algorithms.ECAlgorithm
cryptography.hazmat.backends.openssl.rsa._RSAPrivateKey
jwt.algorithms.ECAlgorithm
key.sign requires padding and algorithm parameters.
$ python -m jwt.help
{ "cryptography": { "version": "3.4.8" }, "implementation": { "name": "CPython", "version": "3.9.5" }, "platform": { "release": "20.6.0", "system": "Darwin" }, "pyjwt": { "version": "2.3.0" } }
Same story on ubuntu 20 VM
Am i missing something?
The text was updated successfully, but these errors were encountered:
contributions are welcome
Sorry, something went wrong.
@alex-hsp can you please provide steps to fully reproduce this? How was key fully generated, etc.
No branches or pull requests
Using
ES256
, i am trying to generate JWT token with following codeprivate key file is .pem with
-----BEGIN RSA PRIVATE KEY-----
insideExpected Result
Expected to generate token. Same code worked 6 months ago.
Actual Result
key is
cryptography.hazmat.backends.openssl.rsa._RSAPrivateKey
sign_obj is
jwt.algorithms.ECAlgorithm
key.sign requires padding and algorithm parameters.
Reproduction Steps
System Information
Same story on ubuntu 20 VM
Am i missing something?
The text was updated successfully, but these errors were encountered: