英文:
I am using docusign-esign node SDK and i want to change the Sender's name(as of now docusign using the Name associated with the account)
问题
以下是代码部分的中文翻译:
const accessToken = await getAccessToken();
const apiClient = new docusign.ApiClient();
apiClient.setBasePath(`${process.env.DOCUSIGN_RESTAPI_BASE_URL}/restapi`);
apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
docusign.Configuration.default.setDefaultApiClient(apiClient);
const envelopesApi = new docusign.EnvelopesApi();
const pdfBuffer = await fetchPdfBuffer(pdfUrl);
const envelopeDefinition = await buildEnvelopeDefinition(parties, pdfBuffer);
const results = await envelopesApi.createEnvelope("7578669", {
envelopeDefinition
});
关于如何使用 envelope 对象定义中的 sender 字段来更改信封的发件人,您可以查看此链接:https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create
至于如何使用 docusign-esign node sdk 实现 Send-On-Behalf 功能,请查阅相关文档或 SDK 的文档,以获取详细的指导和示例代码。
英文:
const accessToken = await getAccessToken();
const apiClient = new docusign.ApiClient();
apiClient.setBasePath(`${process.env.DOCUSIGN_RESTAPI_BASE_URL}/restapi`);
apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
docusign.Configuration.default.setDefaultApiClient(apiClient);
const envelopesApi = new docusign.EnvelopesApi();
const pdfBuffer = await fetchPdfBuffer(pdfUrl);
const envelopeDefinition = await buildEnvelopeDefinition(parties, pdfBuffer);
const results = await envelopesApi.createEnvelope("7578669", {
envelopeDefinition
});
As I am using envelope definition and there is a field with name sender in envelope object definition (<https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create>
How can I use this sender field to change the sender of the envelope?
And how can we use Send-On-Behalf functionality using deocusign-esign node sdk?
答案1
得分: 0
当您调用API创建一个信封时,发送者是用于获取访问令牌的已验证用户。
这意味着您不能更改它,除非为不同的用户获取新的访问令牌。
要做到这一点,除非您希望其他用户每次都要交互式地对DocuSign进行身份验证,您将需要使用JWT身份验证。
使用JWT身份验证时,您在获取访问令牌时指定要代表的用户的userId。
该用户必须首次同意您的应用代表此用户使用API。
要了解更多信息,请阅读此链接:
https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken
英文:
When you make API calls to create an envelope, the sender is the authenticated user that was used to obtain the access token.
That means that you cannot change it without getting a new access token for a different user.
To do that, unless you want that other user to interactively authenticate to DocuSign every time, you will need to use JWT authentication.
With JWT authentication, when you obtain the access token, you specify the userId for the user you want to act on behalf of.
That user must give your app consent once to allow it to use the API of behalf of this user.
To learn more, read this:
https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken
答案2
得分: 0
请注意,您的应用程序可以根据需要创建不同的访问令牌(使用JWT授权流)以代表用户1、用户2等。
DocuSign的OAuth实现不再支持旧的“代表发送”。相反,使用OAuth,您的应用程序可以获取一个令牌来模拟某人,然后可以代表他们发送信封。
然而,一个用户的当前访问令牌数量存在限制,您可以创建这些令牌,因此您应该将它们缓存直到它们过期。
例如,您有两个DocuSign帐户用户(都可以发送信封),Sam和Samantha:
- 应用程序使用JWT授权来获取一个代表Sam的访问令牌。
- 应用程序使用该令牌以Sam的名义发送信封。
- 应用程序缓存Sam的令牌。(记录令牌的过期时间。)
- 应用程序使用JWT授权来获取一个代表Samantha的访问令牌。
- 应用程序使用该令牌以Samantha的名义发送信封。
- 应用程序缓存Samantha的令牌。(记录令牌的过期时间。)
- 应用程序希望以Sam的名义发送另一个信封。它使用缓存的令牌。如果令牌已过期,则使用JWT授权获取新的令牌。
英文:
Note that your application can create different access tokens (using the JWT Grant flow) as needed to send as user 1, user 2, etc.
DocuSign's OAuth implementation does not support the old "Send on behalf of" any more. Instead, using OAuth, your app obtains a token to impersonate someone and can then send an envelope for them.
However, there is a limit to the number of current access tokens for one user that you can create, so you should cache them until they expire.
For example, you have two DocuSign account users (both can send envelopes), Sam and Samantha:
- App uses JWT Grant to get an access token that impersonates Sam
- App uses the token to send an envelope "from" Sam
- App caches Sam's token. (Record the token's expiration time.)
- App uses JWT Grant to get an access token that impersonates Samantha
- App uses the token to send an envelope "from" Samantha
- App caches Samantha's token. (Record the token's expiration time.)
- App wants to send another envelope "from" Sam. It uses the cached token. If the token has expired then use JWT Grant to get a new one.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论