![]() |
AttributeError: '_RSAPrivateKey' object has no attribute 'sign' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: AttributeError: '_RSAPrivateKey' object has no attribute 'sign' (/thread-9874.html) |
AttributeError: '_RSAPrivateKey' object has no attribute 'sign' - saurya1979 - May-02-2018 Hi, I am trying to create JWT token using python 2.7 and receive following error. AttributeError: '_RSAPrivateKey' object has no attribute 'sign' <PYTHON>jwt_token = jwt.encode(payload, self.private_key, algorithm='RS256')</PYTHON> private key is stored in PEM format file. Here is the error log one script execution: Traceback (most recent call last): File "report_sharing.py", line 349, in <module> main() File "report_sharing.py", line 328, in main access_token = ims.get_access_token() File "report_sharing.py", line 82, in get_access_token jwt_token = self.create_jwt() File "report_sharing.py", line 136, in create_jwt jwt_token = jwt.encode(payload, self.private_key, algorithm='RS256') File "/usr/lib64/python2.7/site-packages/jwt/api_jwt.py", line 55, in encode json_payload, key, algorithm, headers, json_encoder File "/usr/lib64/python2.7/site-packages/jwt/api_jws.py", line 105, in encode signature = alg_obj.sign(signing_input, key) File "/usr/lib64/python2.7/site-packages/jwt/algorithms.py", line 313, in sign return key.sign(msg, padding.PKCS1v15(), self.hash_alg()) AttributeError: '_RSAPrivateKey' object has no attribute 'sign' Any clue on this? |