我正在尝试使用他们的SDK进行docusign集成。我已经按照其文档@ https://developers.docusign.com/esign-rest-api/code-examples/config-and-auth中的说明实施了“客户端设置和身份验证”步骤。
我已经设置了我的模拟账户;
// Point to DocuSign Demo (sandbox) environment for requests
public const string RestApiUrl = "https://demo.docusign.net/restapi";
public const string client_id = "{CLIENT_ID}"; //integrator key
public const string client_secret = "{CLIENT_SECRET}";
public const string redirect_uri = "{REDIRECT_URI}";
public void OAuthAuthorizationCodeFlowTest()
{
// Make an API call with the token
ApiClient apiClient = new ApiClient(RestApiUrl);
DocuSign.eSign.Client.Configuration.Default.ApiClient = apiClient;
// Initiate the browser session to the Authentication server
// so the user can login.
Uri accountServerAuthUrl = apiClient.GetAuthorizationUri(client_id, new List<string>(), redirect_uri, "code", stateOptional);
System.Diagnostics.Process.Start(accountServerAuthUrl.OriginalString);
}
我取回了访问代码,并使用下面的代码来获取访问令牌;
// request an access token
string accessToken = apiClient.GetOAuthToken(client_id, client_secret, true, AccessCode);
Console.WriteLine("Access_token: " + accessToken);
我将访问令牌作为承载令牌返回。
我使用下面的代码获取userInfo;
// call the GetUserInfo endpoint
OAuth.UserInfo userInfo = apiClient.GetUserInfo({ACCESS_TOKEN});
string accountId = string.Empty;
// find default account (if multiple present)
foreach (var item in userInfo.GetAccounts())
{
if (item.GetIsDefault() == "true")
{
accountId = item.AccountId();
apiClient = new ApiClient(item.GetBaseUri() + "/restapi");
break;
}
}
return accountId;
现在使用accountId,我试图创建一个信封以使用模板发送电子邮件。我在他们的文档{@ {3}}
中使用以下代码作为共享 EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
// assign recipient to template role by setting name, email, and role name. Note that the
// template role name must match the placeholder role name saved in your account template.
TemplateRole tRole = new TemplateRole();
tRole.Email = "{USER_EMAIL}";
tRole.Name = "{USER_NAME}";
tRole.RoleName = "{ROLE}";
List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };
// add the role to the envelope and assign valid templateId from your account
envDef.TemplateRoles = rolesList;
envDef.TemplateId = "{TEMPLATE_ID}";
// set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent";
// |EnvelopesApi| contains methods related to creating and sending
Envelopes (aka signature requests)
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary =
envelopesApi.CreateEnvelope(accountId, envDef);
我不断收到错误PARTNER_AUTHENTICATION_FAILED,我有一个集成商密钥集-我成功获得了访问令牌。
我还尝试过将配置对象传递到信封中
Configuration cfi = new Configuration(apiClient, accessToken: accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
有人以相同的方式成功使用Docusign吗?