While creating application,clicked the “Generate Public/Private Keypair” & get the JSON file.
From the JSON file,we have copied the content from “privateKey” & create new file (Config.PEM) and updated the “privateKey” values.
the run the below code, getting an error.
from boxsdk import JWTAuth
from boxsdk import Client
auth = JWTAuth(
client_id=‘xxxxxx’,
client_secret=‘xxxxxxxx’,
enterprise_id=‘0’,
jwt_key_id=‘xxxxxx’,
rsa_private_key_file_sys_path=‘C:\Box\config.PEM’,
rsa_private_key_passphrase=‘xxxxxxxxxxx’,
)
access_token = auth.authenticate_instance()
client = Client(auth)
Issue : Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type
C:\Program Files (x86)\Python\Python310>python.exe “C:\Users\arulap\OneDrive - Symphony Summit\Working\Official\Dev\Box\summitorchestration@gmail.com\JWTAuth_Test.py”
Traceback (most recent call last):
File “C:\Users\arulap\OneDrive - Symphony Summit\Working\Official\Dev\Box\summitorchestration@gmail.com\JWTAuth_Test.py”, line 5, in
auth = JWTAuth(
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\boxsdk\auth\jwt_auth.py”, line 108, in init
rsa_private_key = self._normalize_rsa_private_key(
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\boxsdk\auth\jwt_auth.py”, line 207, in _normalize_rsa_private_key
return serialization.load_pem_private_key(
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\cryptography\hazmat\primitives\serialization\base.py”, line 22, in load_pem_private_key
return ossl.load_pem_private_key(data, password)
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\cryptography\hazmat\backends\openssl\backend.py”, line 921, in load_pem_private_key
return self._load_key(
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\cryptography\hazmat\backends\openssl\backend.py”, line 1189, in _load_key
self._handle_key_loading_error()
File “C:\Users\arulap\AppData\Roaming\Python\Python310\site-packages\cryptography\hazmat\backends\openssl\backend.py”, line 1248, in _handle_key_loading_error
raise ValueError(
ValueError: (‘Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).’, _OpenSSLErrorWithText(code=503841036, lib=60, reason=524556, reason_text=b’error:1E08010C:DECODER routines::unsupported’)])
C:\Program Files (x86)\Python\Python310>