I need to pass a private_key_bytes: the byte contents of the RSA private key in api_client.request_jwt_user_token() API. How do I convert RSA private key to byte array?
I'm assuming you're using Python and using our SDK.
Here is a code snippet taken out of our code examples on GitHub:
(this line does it - private_key = cls._get_private_key().encode("ascii").decode("utf-8")
def _jwt_auth(cls):
"""JSON Web Token authorization"""
api_client = ApiClient()
api_client.set_base_path(DS_JWT["authorization_server"])
# Catch IO error
try:
private_key = cls._get_private_key().encode("ascii").decode("utf-8")
except (OSError, IOError) as err:
return render_template(
"error.html",
err=err
)
try:
cls.ds_app = api_client.request_jwt_user_token(
client_id=DS_JWT["ds_client_id"],
user_id=DS_JWT["ds_impersonated_user_id"],
oauth_host_name=DS_JWT["authorization_server"],
private_key_bytes=private_key,
expires_in=3600
)