I have an endpoint that logs in using OAuth 2.0 with JWT Token, with the standard Infor OS Cloud feature, I receive errors and the Token doesn't pass.
Because of this I made a Python script to sign the JWT and with this token contact the methods. This jwt signed, I sent it to the endpoint token and with the token that it returns to me, I should contact the methods...
The strange thing is that I am having errors when using the Cryptography library.
Errors like : scripting.Traceback (most recent call last): File "script", line 1, in <module> File "/var/task/jwt/__init__.py", line 1, in <module> from .api_jwk import PyJWK, PyJWKSet File "/var/task/jwt/api_jwk.py", line 7, in <module> from .algorithms import get_default_algorithms, has_crypto, requires_cryptography File "/var/task/jwt/algorithms.py", line 11, in <module> from .utils import ( File "/var/task/jwt/utils.py", line 7, in <module> from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve File "/var/task/cryptography/hazmat/primitives/asymmetric/ec.py", line 11, in <module> from cryptography.exceptions import UnsupportedAlgorithm, _Reasons File "/var/task/cryptography/exceptions.py", line 9, in <module> from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions ImportError: cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location)
These messages are usually due to compatibility, analyze in Pypi (https://pypi.org/project/cryptography/42.0.7/#files)
and I really can't find the build that would be correct for Infor OS Cloud, what would it be?
Has anyone used this library?, or performed this operation via Script?
In my environment Python works correctly.
The script is very simple (i remove personal data)-->
import jwt
import time
import cryptography
# Configuración
consumer_key = 'CONSUMER_KEY'
#cert_id = 'ID_DEL_CERTIFICADO'
private_key_pem = b"""-----BEGIN PRIVATE KEY-----
51651651
-----END PRIVATE KEY-----"""
# Construir el JWT Header
header = {
'alg': 'PS256',
'typ': 'JWT',
'kid': 'kid_client'
}
# Construir el JWT Payload
payload = {
'iss': consumer_key,
'scope': ['restlets', 'rest_webservices'],
'iat': int(time.time()), # Timestamp actual
'exp': int(time.time()) + 3600, # Expiración en 1 hora
'aud': 'https://server.tokenserver';
}
# Generar el JWT
encoded_jwt = jwt.encode(payload, private_key_pem, algorithm='PS256', headers=header)
# Mostrar el JWT
print(encoded_jwt)
Thanks!, best regards