Some algorithms requires "pip install cryptography". See https://pyjwt.readthedocs.io/en/latest/installation.html#cryptographic-dependencies-optional
Traceback (most recent call last):
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\jwt\algorithms.py", line 350, in prepare_key
RSAPrivateKey, load_pem_private_key(key_bytes, password=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 494, 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).', [<OpenSSLError(code=503841036, lib=60, reason=524556, reason_text=unsupported)>])
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\msal\oauth2cli\assertion.py", line 114, in create_normal_assertion
str_or_bytes = jwt.encode( # PyJWT 1 returns bytes, PyJWT 2 returns str
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\jwt\api_jwt.py", line 73, in encode
return api_jws.encode(
^^^^^^^^^^^^^^^
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\jwt\api_jws.py", line 160, in encode
key = alg_obj.prepare_key(key)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jnguyen-a\AppData\Local\Programs\Python\Python311\Lib\site-packages\jwt\algorithms.py", line 353, in prepare_key
return cast(RSAPublicKey, load_pem_public_key(key_bytes))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. MalformedFraming```
My .PEM has a format similar to below:
```python
-----BEGIN CERTIFICATE-----
fawefaojsfdojiwefoajsdkljskdfasf=wejfasidofjlksdjfalskdjfkwef
asdkfjeiorjqipofkdkdkdfowifeasdfdkfas
sadfoijweoifjaskldfjlskd
-----END CERTIFICATE-----
I received the following issue:
This is my ClientContext code