python - 为 JWT 用户令牌调用 DocuSign API 时出现错误请求。同意?
问题描述
我正在使用 DocuSign API 来请求 JWT 用户令牌:
with open('docusign.pem', mode='rb') as privatefile:
private_key_bytes = privatefile.read()
api_client = ApiClient()
oauth_host_name = 'account-d.docusign.com'
# not real, random:
client_id = 'dff16ff1-de93-477d-a73d-3774ac9932dc'
user_id = '7401f22e-ff2c-4777-9117-5932ace2e71a'
expires_in = 3600
result = api_client.request_jwt_user_token(client_id, user_id,
oauth_host_name,
private_key_bytes,
expires_in,
scopes=(OAuth.SCOPE_SIGNATURE,))
这将返回:
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache', 'Pragma': 'no-cache',
'Content-Type': 'application/json; charset=utf-8', 'Expires': '-1', 'Server':
'Microsoft-IIS/10.0', 'X-AspNetMvc-Version': '5.2', 'X-DocuSign-TraceToken':
'c1d090b7-cefd-4881-80c6-3f1c55ccc5b4', 'X-Content-Type-Options': 'nosniff',
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload,
max-age=15768000', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block;
report=/client-errors/xss', 'X-DocuSign-Node': 'DA2DFE179', 'Date':
'Sun, 23 Aug 2020 15:18:46 GMT', 'Content-Length': '28'})
HTTP response body: b'{"error":"consent_required"}'
那么如何获得“同意”。此页面有两个部分“内部应用程序的管理员同意”和“外部应用程序的管理员同意”:
我不确定如何在沙盒中获得同意。它已经在 DocuSign 中的用户的“权限配置文件”下显示“DS Admin”。
更新
我使用第二种技术“内部应用程序的管理员同意”来获得对设置的同意:
admin_consent_scope=impersonation
response_type=code
scope=openid
而不是登录,我在 DocuSign 网站上收到消息:“您不是组织管理员。请联系您的 DocuSign 管理员。”
如何要求 DocuSign 在我的开发者帐户上启用此功能?
解决方案
请参阅有关授予同意的博客文章。
请注意,被模拟的用户需要同意signature
范围(如果您使用电子签名功能)和impersonation
范围。
对于个人同意,两个范围由一个空格分隔,该空格应输入为%20
编码值。
例子:
https://account-d.docusign.com/oauth/auth?
response_type=code
&scope=signature%20impersonation
&client_id=YOUR_INTEGRATION_KEY
推荐阅读
- javascript - 带有位置的标题:sticky 在收缩时在 chrome 中闪烁
- cassandra - scylla版本升级后需要sstable升级吗?
- csv - 将杂乱的时间数据从 CSV 导入 SPSS
- sapui5 - 已被 CORS 策略阻止:预检响应中的 Access-Control-Allow-Headers 不允许请求标头字段 x-xhr-logon
- mysql - 选择链中具有参考 ID 的所有查询
- mysql - 将 Innodb 表复制到内存表时 MySQL 内存不足
- deployment - 找不到将 ASP.NET MVC5 部署到 IIS7 程序集
- vb6 - VB6中毫秒精度的unix时间戳?
- python-3.x - 为什么这在我的 requests.get 变量上显示为语法错误?
- reactjs - 如何将事件添加到输入反应