首页 > 解决方案 > 使用 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”:“未找到或禁用指定的集成商密钥。为用户指定的帐户无效。”

有人知道是什么问题吗?

标签: javadocusignapi

解决方案


我忘了使用这些行:

    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();

推荐阅读