admin管理员组文章数量:1355132
Developing an anization's internal app to send envelopes/have embedded signing using DocuSign's C# SDKs. Following the Quickstart examples, I am able to do these actions. Since it using the demo/test DocuSign environments, when this application is deployed, the code will need to make calls to the DocuSign production environment.
Since the anization's employees will be using this application, not the customers, the code uses Authorization Code Grants, not JWT Tokens.
So with getting the access token, should the code call SetOAuthBasePath from its instance of DocuSignClient? The SDK says "Use this method to set custom OAuth Base Path." But how will DocuSign know otherwise?
I assume that the UserInfo endpoint call for the User's BaseUri will already have the correct environment (since they were authenticated), and the BaseUri would then be 'pointing' to the appropriate environment. True?
I see C# SDK does have constants we can reference. Should I use these to set when I am in my production environment:
public class DocuSignClient
{
public const string Production_REST_BasePath = ";;
public const string Demo_REST_BasePath = ";;
...
}
public class OAuth
{
...
public static string Demo_OAuth_BasePath = "account-d.docusign";
public static string Production_OAuth_BasePath = "account.docusign";
}
Code example instead of DocuSignClient docuSignClient = new DocuSignClient()
:
protected DocuSignClient GetDocuSignClient(bool isForAuth, bool useProd, string? userBaseUri = null)
{
DocuSignClient rtn = new DocuSignClient();
//DocuSignClient defaults to demo environment
if (isForAuth && useProd)
{
rtn.SetOAuthBasePath(OAuth.Production_OAuth_BasePath);
}
if (!isForAuth && !string.IsNullOrEmpty(userBaseUri))
{
//we should have a User BaseUri, which will be based on the environment authenticated
rtn.SetBasePath(userBaseUri);
}
return rtn;
}
Developing an anization's internal app to send envelopes/have embedded signing using DocuSign's C# SDKs. Following the Quickstart examples, I am able to do these actions. Since it using the demo/test DocuSign environments, when this application is deployed, the code will need to make calls to the DocuSign production environment.
Since the anization's employees will be using this application, not the customers, the code uses Authorization Code Grants, not JWT Tokens.
So with getting the access token, should the code call SetOAuthBasePath from its instance of DocuSignClient? The SDK says "Use this method to set custom OAuth Base Path." But how will DocuSign know otherwise?
I assume that the UserInfo endpoint call for the User's BaseUri will already have the correct environment (since they were authenticated), and the BaseUri would then be 'pointing' to the appropriate environment. True?
I see C# SDK does have constants we can reference. Should I use these to set when I am in my production environment:
public class DocuSignClient
{
public const string Production_REST_BasePath = "https://www.docusign/restapi";
public const string Demo_REST_BasePath = "https://demo.docusign/restapi";
...
}
public class OAuth
{
...
public static string Demo_OAuth_BasePath = "account-d.docusign";
public static string Production_OAuth_BasePath = "account.docusign";
}
Code example instead of DocuSignClient docuSignClient = new DocuSignClient()
:
protected DocuSignClient GetDocuSignClient(bool isForAuth, bool useProd, string? userBaseUri = null)
{
DocuSignClient rtn = new DocuSignClient();
//DocuSignClient defaults to demo environment
if (isForAuth && useProd)
{
rtn.SetOAuthBasePath(OAuth.Production_OAuth_BasePath);
}
if (!isForAuth && !string.IsNullOrEmpty(userBaseUri))
{
//we should have a User BaseUri, which will be based on the environment authenticated
rtn.SetBasePath(userBaseUri);
}
return rtn;
}
Share
Improve this question
edited Mar 28 at 19:19
B Reed
asked Mar 28 at 18:19
B ReedB Reed
456 bronze badges
1
- Thank you for your question! Please accept/check the best answer. Thank you!! – Larry K Commented Mar 29 at 19:29
1 Answer
Reset to default 1The SDKs use two base path URLs: one for the OAuth service, and one for the REST API service.
These paths are set by default to the developer (demo) system.
For production you should:
Explicitly set the OAuth URL (
SetOAuthBasePath
) to the production OAuth systemAfter the user logs in, call
UserInfo
to determine the user's information, including the API Base Path, used by the user's account that will be used (either their default account or another).Set the SDK's REST API base path by using the data from step 2.
Setting the API base path
The BaseUri
attribute in the UserInfo response does not end with /restapi
, needed for the REST API service. So you need to add it explicitly. Here's an example from the C# SDK's test suite which looks for the default account in the UserInfo response.
Link
foreach (OAuth.UserInfo.Account item in userInfo.Accounts)
{
if (item.IsDefault == "true")
{
testConfig.AccountId = item.AccountId;
testConfig.ApiClient.SetBasePath(item.BaseUri + "/restapi");
break;
}
}
The underlying issue is that the Docusign developer environment (demo) has exactly one API base path. In contrast, the production systems have many API base paths. Your code needs to determine which API base path is the right one for the account the current user is a member of (there can be more than one account).
Note that the UserInfo call is used with the OAuth service. That's why it works even though you don't yet know the API base path for the user.
Multiple accounts
Users belong to a default account. They also, often, can belong to multiple accounts. It's a good idea to enable your users to use their default account by default but also to enable them to change which account will be used. And enable your users, for your application, to change their default.
Your questions
So with getting the access token, should the code call SetOAuthBasePath from its instance of DocuSignClient? The SDK says "Use this method to set custom OAuth Base Path." But how will DocuSign know otherwise?
[You should call SetOAuthBasePath explicitly. The default is demo.]I assume that the UserInfo endpoint call for the User's BaseUri will already have the correct environment (since they were authenticated), and the BaseUri would then be 'pointing' to the appropriate environment. True?
[The BaseUri is not used for the UserInfo endpoint, the OAuth base path is used.]
本文标签: docusignapiDocuSignClient setting path based on environmentStack Overflow
版权声明:本文标题:docusignapi - DocuSignClient setting path based on environment - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744019400a2576938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论