How to retrieve production environment endpoint - docusignapi

I've certified my integrator key last week and it was confirmed to go "live" last friday.
Reading this documentation, I now need to determine which production site I am linked to. The problem is that when I follow the instructions, I can't see which site I am linked to :
*The {SERVER} value is determined by where your DocuSign Production account resides.
The easiest way to determine this is to login to your Production DocuSign account and
examine the prefix of the URL. For example, if the URL is:
https://na2.docusign.net/Member/Home.aspx, then replace {SERVER} with “na2” to find
your Production endpoints.
Any help would be appreciated
is there a way to retrieve the Production URL from an envelope ?
envelopeApi.GetEnvelope() ?

Use the Login_Information API to retrieve your BaseUrl.
Here is the code using the C# SDK
string _username = "<Add your User Name>";
string _password = "<Add your Password>";
string _integratorKey = "<Add your Integrator Key>";
string DOCUSIGN_URI = "https://www.docusign.net/restapi";
string _authHeader;
public string Init()
{
_authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
// initialize client for desired environment (for production change to www)
ApiClient apiClient = new ApiClient(DOCUSIGN_URI);
Configuration.Default.ApiClient = apiClient;
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", _authHeader);
// we will retrieve this from the login API call
string accountId = null;
/////////////////////////////////////////////////////////////////
// STEP 1: LOGIN API
/////////////////////////////////////////////////////////////////
// login call is available in the authentication api
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();
// parse the first account ID that is returned (user might belong to multiple accounts)
accountId = loginInfo.LoginAccounts[0].AccountId;
string baseUrl = loginInfo.LoginAccounts[0].BaseUrl;
// Update ApiClient with the new base url from login call
apiClient = new ApiClient(baseUrl);
return accountId;
}

Related

Post Go Live issue with Docusign using node.js

Here is my issue:
We integrated docusign in our application, server side with nodejs using this tutorial https://github.com/docusign/docusign-node-client ("OAuth JSON Web Token (JWT) Grant" section)
We have done the "Go Live Process": our application is registered in our production account
We have replaced the test config to the production config.
When we try to create an envelope, we get the following error:
PARTNER_AUTHENTICATION_FAILED: The specified Integrator Key was not found or is disabled. Invalid account specified for user
What am I doing wrong ?
async function docusignInit() {
var options;
var env = [40077,50077].indexOf(config.main.port) != -1 ? 'test' :'prod';
if (env == "test") {
options = {
basePath: restApi.BasePath.DEMO,
oAuthBasePath: oAuth.BasePath.DEMO
}
} else {
options = {
oAuthBasePath: "account.docusign.com",
// We called https://account.docusign.com/oauth/userinfo to found the uri
basePath:"https://eu.docusign.net/restapi/"
}
}
// in production, We must do
// var apiClient = new docusign.ApiClient(options.basePath);
// Otherwise, we get "Error: getaddrinfo ENOTFOUND undefined undefined:443"
var apiClient = new docusign.ApiClient(options.basePath);
var privateKeyFile = fs.readFileSync(`./server/docusign/keys/${env}/private.PEM`);
var res = await apiClient.requestJWTUserToken(config.docusign.integratorKey, config.docusign.userName, [oAuth.Scope.IMPERSONATION, oAuth.Scope.SIGNATURE], privateKeyFile, 3600)
var token = res.body.access_token;
apiClient.addDefaultHeader('Authorization', 'Bearer ' + token);
docusign.Configuration.default.setDefaultApiClient(apiClient);
await sendDocusign({
userId: 1,
firstName: 'foor',
lastName: 'bar',
email:'foo#bar;'
})
}
async function sendDocusign(role) {
var envDef = new docusign.EnvelopeDefinition();
envDef.emailSubject = 'Please signe this';
envDef.templateId = config.docusign.templateId;
var role = new docusign.TemplateRole();
role.roleName = "roleName";
role.clientUserId = role.userId;
role.name = role.firstName + " " + role.lastName;
role.email = role.email;
envDef.allowReassign = false;
envDef.templateRoles = [role];
envDef.status = 'sent';
var envelopesApi = new docusign.EnvelopesApi();
return await envelopesApi.createEnvelope(config.docusign.userAccountId, {
'envelopeDefinition': envDef
})
}
As you are able to generate AccesToken properly in PROD with PROD RSA KeyPair, so please check the endpoint which you using to make API calls to create an envelope. In demo it is always demo.docusign.net but in PROD it will be a different value depending on where you PROD account exists in the DocuSign data center. For instance if your PROD account is in NA1, then hostname will be will be www.docusign.net; if it is NA2 then hostname will be na2.docusign.net etc.
So it is recommended to make a /userinfo API call with the Access token to know the baseURI to make calls related to envelope. To get the base URI, call the /oauth/userinfo endpoint, supplying your application’s access token as a header.
For the developer sandbox environment, the URI is
https://account-d.docusign.com/oauth/userinfo
For the production environment, the URI is
https://account.docusign.com/oauth/userinfo
Documentation related to /userinfo API call is available here. Once you know you BaseURI then append this baseURI with envelopes related endpoint like below:
{base_uri} + "/restapi/v2.1/accounts/" + {account_id}
considering your error seems that you're missing the integratorKey or you're writing it in the wrontg way. According to that LINK is possible that you miss the brackets inside the intregrator key?
The integrator key must be placed in front of the user ID that is in
the Username node of the UsernameToken. The integrator key must be
wrapped with brackets, “[ and ]”.
An example of the api in the above documentation:
<soap:Header>
<wsa:Action>http://www.docusign.net/API/3.0/GetRecipientEsignList</wsa:Action>
<wsa:MessageID>uuid:3f9d7626-c088-43b4-b579-2bd5e8026b17</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://demo.docusign.net/api/3.0/api.asmx</wsa:To>
<wsse:Security soap:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-8838aa24-9759-4f85-8bf2-26539e14f750">
<wsu:Created>2006-04-14T14:29:23Z</wsu:Created>
<wsu:Expires>2006-04-14T14:34:23Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-7c7b695e-cef7-463b-b05a-9e133ea43c41">
<wsse:Username>[Integrator Key Here]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
<wsse:Nonce>SjlScsL5q3cC1CDWrcMx3A==</wsse:Nonce>
<wsu:Created>2006-04-14T14:29:23Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>

Bad request while trying to get authToken using docusign API

I am new to docuSign API and I followed the code sample for C# in DocuSign guide site. I failed at the step while I was trying to get AuthToken. Part of my code as below, basically the same as the DocuSign sample,
public void OAuthAuthorizationCodeFlowTest()
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// 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.
string accountServerAuthUrl =
apiClient.GetAuthorizationUri(client_id, redirect_uri, true,
stateOptional);
System.Diagnostics.Process.Start(accountServerAuthUrl);
string accessToken = apiClient.GetOAuthToken(client_id,
client_secret, true, AccessCode);
// login call is available in the authentication api
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();
// parse the first account ID that is returned (user might belong to
multiple accounts)
AccountId = loginInfo.LoginAccounts[0].AccountId;
BaseUri = loginInfo.LoginAccounts[0].BaseUrl;
Console.WriteLine("accountId: " + AccountId);
Console.WriteLine("base_uri: " + BaseUri);
The client_id is my integrator key, the client_secret is the secret key related to that integrator key, right? I checked them many times, no problem. I am confused now why am I still getting 400 error. Please shed me some light here, thanks!!!
System.Diagnostics.Process.Start(accountServerAuthUrl); will open it on a browser, and once you have done successful authentication then browser will be redirected with the query parameter code=.... in the callback url (redirect_uri)
The code in browser needs to be read by your WEBApp, and then you need to call below code to generate the AccessToken:
string accessToken = apiClient.GetOAuthToken(client_id,
client_secret, true, AccessCode);
Below code is one part, to open the browser, ideally it is for testing purpose on a Standalone system, on a WEBApp you will redirect the browser to accountServerAuthUrl
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.
string accountServerAuthUrl = apiClient.GetAuthorizationUri(client_id, redirect_uri, true, stateOptional);
System.Diagnostics.Process.Start(accountServerAuthUrl);
}
Below code is run when user is authenticated by the DocuSign on the browser and browser is redirected to the redirect_uri with code=..., your Webapp will read this code and send it as AccessCode and will call below code from your controller,
string accessToken = apiClient.GetOAuthToken(client_id, client_secret, true, AccessCode);

Create Envelope Issue

Envelope creation was working well on the sandbox environment.
After I made the integrator key live, and used it with live account, I am getting following error:
{"Error calling CreateEnvelope: "}
I am currently use Rest Api of Docusign.
I am able to successfully create an envelope from postman.
But I am unable from my application
Sample Code:
ApiClient apiClient = Configuration.Default.ApiClient;
string authHeader = "{\"Username\":\"" + username+ "\",
\"Password\":\"" + password+ "\",
\"IntegratorKey\":\"" + IntegratorKey + "\"}";
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();
EnvelopeDefinition def = new EnvelopeDefinition();
def.Status = "sent";
def.EmailBlurb = "Body";
def.EmailSubject = "Subject";
def.TemplateId = “TemplateId”;
def.TemplateRoles = new List<TemplateRole>()
{
new TemplateRole {
Email = "test#test.com",
Name = "test test",
RoleName = "all"
}
};
EnvelopesApi envelopesApi = new EnvelopesApi(loginInfo.LoginAccounts[0].BaseUrl);
envelopesApi.CreateEnvelope(loginInfo.LoginAccounts[0].AccountId,def);
If your app was really truly working via the demo environment, then there are only a couple of issues involved in moving to production.
Your integration key needs to be promoted to the production platforms.
You need a user name (email) and password from a production account.
You need to choose the right production platform for your API calls.
Choosing the right production platform
See the docs. You need to determine which production platform the user's account is on. This can be done dynamically or statically.
The name of the platform determines the URL used for API calls.

ConfigureJwtAuthorizationFlow - The specified Integrator Key was not found or is disabled

I am using DocuSign C# SDK (sorry I am new to this) doing a POC at work - created integration key in the demo account.
Using the below example to test authentication.
https://github.com/docusign/docusign-csharp-client/blob/master/README.md
I keep getting this error - The specified Integrator Key was not found or is disabled -- even after creating the integration key again.
const string docuSignDemoIntegrationKey = "2ce4-3508-f3b-da8b74d79daf";
const string docuSignDemoApiUserName = "a1f8--4db8-9a39-2bd4f175";
string oauthBasePath = "account-d.docusign.com";
string privateKeyFilename = #"C:\WorkStation\Projects\DocuSign\PrivateKey2.pem";
int expiresInHours = 1;
string host = "https://demo.docusign.net/restapi";
string accountId = string.Empty;
ApiClient apiClient = new ApiClient(host);
apiClient.ConfigureJwtAuthorizationFlow(docuSignDemoIntegrationKey, docuSignDemoApiUserName, oauthBasePath, privateKeyFilename, expiresInHours);
AuthenticationApi authApi = new AuthenticationApi(apiClient.Configuration);
LoginInformation loginInfo = authApi.Login();
As Ergin mentioned in his comment, you need to provide both the client_id (integration key) and the private key in your call.

DocuSign Documents retrieval

I am trying to retrieve documents from DocuSign server .I am sending account id and document id as a parameter .Using below method to get doclist from docusign server .
EnvelopeDocumentsResult docsList = envelopesApi.ListDocuments(accountID, envelopeid);
I am getting this error :
The specified Integrator Key was not found or is disabled. An
Integrator key was not specified.
ListDocuments method accepting only two parameters but it is showing integrator key is missing .
Please help how can I fix this issue?
It looks like you may be using the C# client (https://github.com/docusign/docusign-csharp-client)?
If so, please note the formation of the authHeader in their sample code, eg
// configure 'X-DocuSign-Authentication' header
string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
and follow their sample code further down about how to login BEFORE instaciating and using envelopesApi (as ergin mentioned) eg:
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();

Resources