docusignapi - 将 RSA 私钥转换为字节数组
问题描述
我需要传递一个private_key_bytes: api_client.request_jwt_user_token() API中 RSA 私钥的字节内容。如何将 RSA 私钥转换为字节数组?
解决方案
我假设您正在使用 Python 并使用我们的 SDK。这是从我们在 GitHub 上的代码示例中提取的代码片段:(这一行可以做到 - 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
)
推荐阅读
- php - 如何拥有具有多个变量的函数
- mysql - SQLSTATE[HY000] [1045] 用户 MySQL 错误的访问被拒绝
- javascript - 仅将文本区域添加到一页
- javascript - 插入时sql查询失败
- c - 评估 sizeof 会提高性能 C
- informatica - 要求是在 Informatica 云中的应用程序集成中使用 API 将数据从 Salesforce 对象提取到 CSV 文件
- amazon-web-services - Aws Ec2 实例自动停止
- c++ - 更快地将子字符串匹配到字符串列表
- python - 将空的“主”df 与从嵌套字典构建的多个动态生成的 df 相结合
- openvpn - Openvpn Invalid Previx Length and RTNETLINK 答案:文件存在