java - 使用 Java PARTNER_AUTHENTICATION_FAILED 列出信封状态更改
问题描述
我正在尝试获取已发送信封的所有状态。我正在关注这个例子:https ://developers.docusign.com/esign-rest-api/code-examples/code-example-list-envelope-status-changes#run-the-examples 。
@Component
@EnableScheduling
public class VerificadorDeAssinaturas {
@Autowired
private DocuSignProperties docuSignProperties;
private ApiClient apiClient;
@Scheduled(cron = "0 0/1 * * * *")
public EnvelopesInformation verificaNovasAssinaturas() throws IllegalArgumentException, IOException, ApiException {
this.apiClient = new ApiClient(this.docuSignProperties.getBaseUrl());
apiClient.addDefaultHeader("Authorization", "Bearer " + getTokenAcesso());
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
ListStatusChangesOptions options = envelopesApi.new ListStatusChangesOptions();
LocalDate date = LocalDate.now().minusDays(30);
options.setFromDate(date.toString("yyyy/MM/dd"));
EnvelopesInformation results = envelopesApi.listStatusChanges(this.docuSignProperties.getUserId(), options);
return results;
}
private byte[] getByteFile() {
byte[] privateKeyBytes = null;
try {
privateKeyBytes = FileCopyUtils.copyToByteArray(
new ClassPathResource(this.docuSignProperties.getPrivateKeyFilename()).getInputStream());
} catch (IOException | IllegalArgumentException ex) {
ex.printStackTrace();
}
return privateKeyBytes;
}
private String getTokenAcesso() throws IllegalArgumentException, IOException, ApiException {
OAuth.OAuthToken oAuthToken = apiClient.requestJWTUserToken(this.docuSignProperties.getIntegratorKey(), this.docuSignProperties.getUserId(), getScopes(), getByteFile(), 3600);
return oAuthToken.getAccessToken();
}
private List<String> getScopes(){
List<String> scopes = new ArrayList<>();
scopes.add(OAuth.Scope_SIGNATURE);
return scopes;
}
}
在这一行:
EnvelopesInformation results = envelopesApi.listStatusChanges(this.docuSignProperties.getUserId(), options);
我收到此错误:“errorCode”:“PARTNER_AUTHENTICATION_FAILED”,“message”:“未找到或禁用指定的集成商密钥。为用户指定的帐户无效。”
有人知道是什么问题吗?
解决方案
我忘了使用这些行:
com.docusign.esign.client.auth.OAuth.UserInfo userInfo = apiClient.getUserInfo(oAuthToken.getAccessToken());
apiClient.setBasePath(userInfo.getAccounts().get(0).getBaseUri() + this.docuSignProperties.getBasePath());
Configuration.setDefaultApiClient(apiClient);
String accountId = userInfo.getAccounts().get(0).getAccountId();
推荐阅读
- django - 如何在连接表上的两个外键之间强制执行数据库约束?
- javascript - Webpack如何将模块填充在窗口关闭中?
- python - 来自 url 的 Json - 数组中的数组
- docker - 有没有办法通过 Jenkins 插件将 docker 图像上传到工件?
- kubernetes - Google Kubernetes Engine Service loadBalancerSourceRanges 不允许在 IP 范围内连接
- python - 如何避免在 django 的测试目录中循环导入?
- lightgbm - LightGBM ranker 函数使用什么评估指标
- python - 当将字典键作为参数传递时,如何将函数结果返回到 Python 中的字典值?
- c# - 如何在 WPF 应用程序中的 SOAP 客户端的“Set-Cookie”标头响应的新请求中设置“Cookie”标头
- javascript - 使用 vue.js 从 api 调用中渲染转义的 HTML