Unable to test docusign in SOAPUI - docusignapi

I ma trying to test docusign REST API using soapui. But it throwing an error
{
"errorCode": "PARTNER_AUTHENTICATION_FAILED",
"message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
}
I have an demo account and integration key setup. Please help.
Thanks
Bharat

Looks like you are specifying the wrong integrator Key.
If you are using the legacy authentication Header, make sure you are passing it as follows.
<DocuSignCredentials>
<Username>developer#example.com</Username>
<Password>S3cre+p455w0Rd</Password>
<IntegratorKey>your integrator key</IntegratorKey>
</DocuSignCredentials>'
If you are using oAuth. Look at this documentation.

Using Json via Rest API at https://demo.docusign.net/restapi/v2 , always remember to include below code for all your requests to DocuSign.
string authHeader = "{\"Username\":\"" + _username + "\", \"Password\":\"" + _password + "\", \"IntegratorKey\":\"" + _integratorKey + "\"}";
WebRequest req = WebRequest.Create(url);
req.Headers.Add("X-DocuSign-Authentication", authHeader);

Related

DocuSign Implicit Grant with Salesforce

I am integrating DocuSign with salesforce using Rest API in order to send the envelopes.
Before sending any envelopes I was working on an Implicit grant in order to generate a token but I am not sure what is the right way to get the token.
I am using the GET method but I am getting the response in HTML format.
public class SendDocumentsWithDocuSign {
public void test(){
String accountID = 'a6e74d5a-****-****-****-28f3bec67ccf';
String userName = 'f2326e06-****-****-****-a1aee682da08';
String passWord = 'password#123';
String integrationKey = 'b19b477c-****-****-a8a5-8ff88ea771cc';
String templateID = '5259faf7-****-****-a493-ba19ce5d633c';
String redirectURL='https://www.salesforce.com';
//Request the implicit grant
String TOKEN_URL = 'https://account-d.docusign.com/oauth/auth?response_type=token&scope=signature&client_id='+integrationKey+'&redirect_uri='+redirectURL;
String authenticationHeader =
'<DocuSignCredentials>' +
'<Username>' + userName+ '</Username>' +
'<Password>' + password + '</Password>' +
'<IntegratorKey>' + integrationKey + '</IntegratorKey>' +
'</DocuSignCredentials>';
HttpRequest httpreq = new HttpRequest();
HttpResponse httpres = new HttpResponse();
Http httpCall = new Http();
httpreq.setEndpoint(TOKEN_URL);
httpreq.setMethod('GET');
//httpreq.setHeader('X-DocuSign-Authentication', authenticationHeader);
httpreq.setHeader('Content-Type', 'application/json');
httpreq.setHeader('Accept', 'application/json');
httpres = httpCall.send(httpreq);
System.debug(httpres.getHeaderKeys());
System.debug(httpres.getHeader('X-DocuSign-TraceToken'));
System.debug(httpres.getHeader('Set-Cookie'));
System.debug(httpres.getBody());
}
}
I am getting the below Output.
[32]|DEBUG|(X-DocuSign-Node, X-Content-Type-Options, X-DocuSign-TraceToken, Pragma, Date, X-Frame-Options, Strict-Transport-Security, Cache-Control, Content-Security-Policy, Set-Cookie, ...)
[33]|DEBUG|4d4cac98-7cc9-4b3e-a1fe-c12e871b7065
[34]|DEBUG|__RequestVerificationToken=ARFea2sGN3iGpAjBGHGwCJcB0; path=/; secure; HttpOnly
[35]|DEBUG|
input name="__RequestVerificationToken" type="hidden" value="ARFea2sGN3iGpAjBGHGwCJcAAAAA0"
I want to fetch the access token to call the REST API as given in the DocuSign document. https://developers.docusign.com/platform/auth/implicit/implicit-get-token
To use the DocuSign APEX toolkit, you need to follow the toolkit's authentication methods since that's the only way to use the (needed) integration key from the APEX toolkit.
See the toolkit's authentication instructions.
If you're not using the APEX toolkit then you need to work within the capabilities of SalesForce. Named Credentials is one approach. Here's another.

Hue API remote Basic Authentication

I'm having issues using the Basic Authentication method for the Hue remote API.
When POSTing to https://api.meethue.com/oauth2/token?code={code}&grant_type=authorization_code with the built Authorization-header I get this response:
{
"fault": {
"faultstring": "Invalid client identifier {0}",
"detail": {
"errorcode": "oauth.v2.InvalidClientIdentifier"
}
}
}
I assume then that I am building the token in the wrong way, but the docs (see Basic Authentication) is a bit vague on what to actually do.
The docs says that I should send a header via this format: Authorization: Basic <base64(clientid:clientsecret)> and that it should be encoded in base-64:
you would need to send a Basic authorization header that includes a base64 encrypted hash of your clientid and clientsecret.
And from the Digest-method, I assume MD5 is used and then digested to base-64.
Here's what I've tried, all with the same error-code:
'Basic ' + crypto.createHash('md5').update(clientId + clientSecret).digest('base64')
'Basic ' + crypto.createHash('md5').update(clientId + ':' + clientSecret).digest('base64')
'Basic ' + (clientId + ':' + clientSecret).toString('base64')
'Basic ' + (clientId + clientSecret).toString('base64')
What more is there to try?
#Tokfrans
you can create a test token with clientid:secret by using the site
https://www.base64encode.org/
it will give you a valid token that you can use with Basic authentication
keep in mind that you first need to get a code which you can then use to get a accesstoken
https://api.meethue.com/oauth2/auth?clientid=xxxxxx&appid=xxxxx&deviceid=xxxx&devicename=xxxx&state=xxxx&response_type=code

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();

Docusign Signing Groups

I created an account in the Docusign Sandbox to evaluate the product. My main goal is to create a signing group but before that I would like to get the list of signing groups with RestSharp.
[EDIT]
docusign.configureApiClient("https://demo.docusign.net/restapi");
var login = docusign.LoginDocusign(USERNAME, PASSWORD);
var client = new RestClient(login.BaseUrl);
var request = new RestRequest("signing_groups", Method.GET);
string authHeader = "{\"Username\":\"" + USERNAME + "\", \"Password\":\"" + PASSWORD + "\", \"IntegratorKey\":\"" + INTEGRATOR_KEY + "\"}";
request.AddHeader("X-DocuSign-Authentication", authHeader);
IRestResponse response = client.Execute(request);
var content = response.Content;
Debug.WriteLine(content);
However the content returns
error code : "ACCOUNT_LACKS_PERMISSIONS"
message: "This Account lacks sufficient permissions."
I thought demo accounts have almost the same permissions as a premium account. Is there a setting somewhere to enable this?
I am certain that the authentication is correct when I request for list of groups, the content returns all of my groups.
var request = new RestRequest("groups", Method.GET);
I'm not familiar with RestSharp, but my suspicion is that there's a problem with the request.
To diagnose: first start with making a call to DocuSign and use the Request Log facility to see what is being sent.
If the incoming request can't be matched to your account, or fails some initial filters, then the request will not reach your account. In that case, use requestb.in (free) to see what you're sending.
Also, I don't see where you are requesting the accountId and base URL from DocuSign. (Using https://demo.docusign.net/restapi/v2/login_information)
That's the first step for an API integration since you can't predict which platform the user's account is running on.

Using APIServiceSoapClient for DocuSign

Im tring to user the DocuSign api/sdk to send a document for someone to sign. The examples say something like:
//.NET
APIServiceSoapClient apiService = new APIServiceSoapClient();
apiService.ClientCredentials.UserName.UserName = "Your DocuSign UserName here";
apiService.ClientCredentials.UserName.Password = "Your DocuSign Password here";
Which I of course have tried but its not working.
I get the following error:
Security requirements are not satisfied because the security header is not present in the incoming message.
Ive tried
var username = "myemail";
var pass = "mypass";
var iteratorKey = "iteratorkey";
APIServiceSoapClient apiService = new APIServiceSoapClient();
apiService.ClientCredentials.UserName.UserName = username;
//also tried ...UserName = "[" + iteratorKey + "]" + username;
apiService.ClientCredentials.UserName.Password = pass;
Is this not where all security requirements are met? maybe? Using APIService not DSAPIService if that makes a difference.
I ended up having to use a different way to pass in the credentials. Which I found somewhere else. Im still not sure how to correctly use the other method I tried though so if anyone knows how to use the other method it would be great just because the code is neater and easier to follow.
string auth = #"<DocuSignCredentials>
<Username>email</Username>
<Password>pass</Password>
<IntegratorKey>key</IntegratorKey>
</DocuSignCredentials>";
DSAPIServiceSoapClient apiService = new DSAPIServiceSoapClient();
using (var scope = new System.ServiceModel.OperationContextScope(apiService.InnerChannel))
{
var httpRequestProperty = new System.ServiceModel.Channels.HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("X-DocuSign-Authentication", auth);
System.ServiceModel.OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] = httpRequestProperty;
EnvelopeStatus envStatus = apiService.CreateAndSendEnvelope(envelope);
return envStatus.EnvelopeID;
}
There are two ways to pass member credentials through DocuSign's SOAP API (as opposed to the newer REST API):
SOAP Header via WS-Security UsernameToken
HTTP Header via a custom field “X-DocuSign-Authentication”
The Account Management API only supports the HTTP Header authentication method, while all others can support either method.
Additionally, the DocuSign SOAP API has two API end points: API.asmx and DSAPI.asmx. The API.asmx end point requires the WS-Security UsernameToken in the SOAP header authentication. The DSAPI.asmx and AccountManagement.asmx end points require the HTTP Header authentication method.

Resources