Docusign 指定的集成商密钥未找到或已禁用

Docusign The specified Integrator Key was not found or is disabled

我正在尝试以下代码 as mentioned here,

public string loginApi(string usr, string pwd)
{
// we set the api client in global config when we configured the client 
ApiClient apiClient = Configuration.Default.ApiClient;
string authHeader = "{\"Username\":\"" + usr + "\", \"Password\":\"" + pwd + "\", \"IntegratorKey\":\"" + INTEGRATOR_KEY + "\"}";
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

// we will retrieve this from the login() results
string accountId = null;

// the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();

// find the default account for this user
foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
{
    if (loginAcct.IsDefault == "true")
    {
        accountId = loginAcct.AccountId;
        break;
    }
}
if (accountId == null)
{ // if no default found set to first account
    accountId = loginInfo.LoginAccounts[0].AccountId;
}
return accountId;
}

它不工作,我用 try catch 包裹它并注意到这个错误,

Error calling Login: {

"errorCode": "PARTNER_AUTHENTICATION_FAILED",

"message": "The specified Integrator Key was not found or is disabled."

}

当我看着提琴手时,

请求将发送到 www.docusign.net,我想将其发送到 https://demo.docusign.net。如何更改此代码的基本 Uri?

好的,问题解决了。错误信息具有误导性。

第 1 步 - 看来我需要构建配置 object。

 ApiClient client = new ApiClient(basePath:  "https://demo.docusign.net/restapi");
            Configuration cfg = new Configuration(client);

第 2 步 - 需要设置身份验证 header

cfg.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

第 3 步传递给 Api

的构造函数
 AuthenticationApi authApi = new AuthenticationApi(cfg);