简体   繁体   English

DocuSign REST API - 以其他用户身份发送信封

[英]DocuSign REST API - Send envelopes as a different user

I am setting up a web app that uses DocuSign to send an eSignature request to various different clients.我正在设置一个 Web 应用程序,该应用程序使用 DocuSign 向各种不同的客户端发送电子签名请求。 Each request to a different client needs to have a different displayed sender name and email address, and not just the main name on the DocuSign account.对不同客户端的每个请求都需要显示不同的发件人姓名和电子邮件地址,而不仅仅是 DocuSign 帐户上的主要名称。 The completed e-signed form also needs to be emailed to these client-specific email addresses as well.完成的电子签名表格也需要通过电子邮件发送到这些客户特定的电子邮件地址。

I have created a new second login within my DocuSign account as a test, and am able to get it to display this login's name/email, but only when I generate an entirely new temporary demo API key from that account and use that in the application.我在我的 DocuSign 帐户中创建了一个新的第二个登录名作为测试,并且能够让它显示此登录名/电子邮件,但只有当我从该帐户生成一个全新的临时演示 API 密钥并在应用程序中使用它时.

I am able to change the reply email by altering the EnvelopeDefinition.EmailSettings.ReplyEmailAddressOverride field, but the envelope email sent to signers still displays the main account name/email, and signed docs are emailed to the main email.我可以通过更改 EnvelopeDefinition.EmailSettings.ReplyEmailAddressOverride 字段来更改回复电子邮件,但发送给签名者的信封电子邮件仍显示主帐户名/电子邮件,并且签名文档将通过电子邮件发送到主电子邮件。

How can I change the name and email address sent to the signer and the email address signed docs are received by?如何更改发送给签名者的姓名和电子邮件地址以及接收签名文档的电子邮件地址?

            string signerName = "John Doe";
            string signerEmail = "johndoe@fake.com";
            string accessToken = "{The DocuSign API KEY}";
            string accountId = "{The DocuSign Account Number}";

            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name = "Please Sign This Form",
                FileExtension = "docx",
                DocumentId = "1"
            };
            Document[] documents = new Document[] { document };

            Signer signer = new Signer
            {
                Email = signerEmail,
                Name = signerName,
                RecipientId = "1",
                RoutingOrder = "1"
            };

            Tabs tabs = new Tabs();

            SignHere signHereTab = new SignHere
            {
                DocumentId = "1",
                PageNumber = "1",
                AnchorString = "Patient Signature or Mark",
                AnchorUnits = "pixels",
                AnchorXOffset = "10",
                AnchorYOffset = "-18",
                Width = "160"
            };
            List<SignHere> signatureTabs = new List<SignHere>();
            signatureTabs.Add(signHereTab);
            tabs.SignHereTabs = signatureTabs;

            FullName nameTab = new FullName
            {
                DocumentId = "1",
                PageNumber = "1",
                TabLabel = "Full Name",
                Value = signerName,
                AnchorUnits = "pixels",
                AnchorString = "Name:",
                AnchorXOffset = "133",
                AnchorYOffset = "5"
            };
            List<FullName> nameTabs = new List<FullName>();
            nameTabs.Add(nameTab);
            tabs.FullNameTabs = nameTabs;

            signer.Tabs = tabs;

            Recipients recipients = new Recipients
            {
                Signers = new List<Signer> { signer }
            };
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = "Please Sign Form",
                Documents = new List<Document>(documents),
                Recipients = recipients,
                Status = "sent"
            };

            //Override the reply email address
            envelopeDefinition.EmailSettings = new EmailSettings();
            envelopeDefinition.EmailSettings.ReplyEmailAddressOverride = "client-specific-email@fake.com";
            envelopeDefinition.EmailSettings.ReplyEmailNameOverride = "Test Account";

            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken); 

            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
            EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

If your app wants to send as various different people (users) on your DocuSign account, the right answer is to impersonate them using the OAuth JWT flow.如果您的应用程序想要在您的 DocuSign 帐户上以各种不同的人(用户)的身份发送,正确的答案是使用 OAuth JWT 流程impersonate他们。 See the JWT examples, the eg-01 code examples, on github.com/docusign.请参阅 github.com/docusign 上的 JWT 示例,eg-01 代码示例。

For each user impersonated, your app will need their user guid from DocuSign.对于模拟的每个用户,您的应用程序都需要来自 DocuSign 的用户 guid。 It is available from the Users section of the administration tool.它可从管理工具的“用户”部分获得。

The old legacy authentication header technique is not supported for new apps.新应用程序不支持旧的旧式身份验证标头技术。

Since you are using the Token Generator on Developer Center https://developers.docusign.com/oauth-token-generator , your choice for now is to login to that website with the other user you wish to use and that token would be for that other user.由于您在开发人员中心https://developers.docusign.com/oauth-token-generator上使用令牌生成器,您现在的选择是与您希望使用的其他用户一起登录该网站,该令牌将用于那个其他用户。

Long term I would suggest you look into using JWT Auth.从长远来看,我建议您考虑使用 JWT 身份验证。 That has the option of specifiying the userId and you can switch users.可以选择指定用户 ID,您可以切换用户。 You also have to use real auth if you want to move your app out of the developer sandbox and into production anyway.如果您想将您的应用程序从开发人员沙箱中移出并投入生产,您还必须使用真正的身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM