Docusign : One or both of Username and Password are invalid - docusignapi

I was testing Docusign PHP API and trying the following code:
$envelopeId = '3e979aac-1d8d-4ab9-rand-envelopid';
$api = new APIService();
$api->setCredentials('devaccountemail', 'devaccountpassword');
$userName = 'Test Signer';
$userEmail = 'random#randor.com';
$userId = '457';
$RequestRecipientTokenParams = new RequestRecipientToken();
$RequestRecipientTokenParams->EnvelopeID = $envelopeId;
$RequestRecipientTokenParams->Username = $userName;
$RequestRecipientTokenParams->Email = $userEmail;
$RequestRecipientTokenParams->ClientUserID = $userId;
$RequestRecipientTokenParams->AuthenticationAssertion->AssertionID = rand(0, 999);
$RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationInstant = date("Y")."-".date("m")."-".date("d")."T00:00:00.00";
$RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationMethod = RequestRecipientTokenAuthenticationAssertionAuthenticationMethod::Email;
$RequestRecipientTokenParams->AuthenticationAssertion->SecurityDomain = "local IP Address";
$RequestRecipientTokenParams->ClientURLs->OnAccessCodeFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnAccessCodeFailed";
$RequestRecipientTokenParams->ClientURLs->OnCancel = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnCancel";
$RequestRecipientTokenParams->ClientURLs->OnDecline = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnDecline";
$RequestRecipientTokenParams->ClientURLs->OnException = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnException";
$RequestRecipientTokenParams->ClientURLs->OnFaxPending = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnFaxPending";
$RequestRecipientTokenParams->ClientURLs->OnIdCheckFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnIdCheckFailed";
$RequestRecipientTokenParams->ClientURLs->OnSessionTimeout ="https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSessionTimeout";
$RequestRecipientTokenParams->ClientURLs->OnSigningComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSigningComplete";
$RequestRecipientTokenParams->ClientURLs->OnTTLExpired = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnTTLExpired";
$RequestRecipientTokenParams->ClientURLs->OnViewingComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnViewingComplete";
$RequestRecipientTokenResponse = $api->RequestRecipientToken($RequestRecipientTokenParams);
I got the following Error:
SoapFault : One or both of Username and Password are invalid.
The credentials provided by me are valid and I can login to demo.docusign.net account with these credentials. I'm not sure where I'm doing it wrong.
Here is the SOAP request that is being generated:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.docusign.net/API/3.0"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<SOAP-ENV:Header>
<wsa:Action>http://www.docusign.net/API/3.0/RequestRecipientToken</wsa:Action>
<wsa:To>https://www.docusign.net/API/3.0/api.asmx</wsa:To>
<wsa:MessageID>uudi:638fd49c-2516-12a9-8159-17a9c602975e</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2013-09-18T12:30:20Z</wsu:Created>
<wsu:Expires>2013-09-18T12:35:20Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken>
<wsse:Username>bhargav.bonu#somedomain.com</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-
token-profile-1.0#PasswordText">mypassword</wsse:Password>
<wsse:Nonce>0PZkAUVbHHiyjV8KZrN6x2x0S6cQ5WbAjTH4yn8dnc4=</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
utility-1.0.xsd">2013-09-18T12:29:18Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:RequestRecipientToken>
<ns1:EnvelopeID>3e979aac-1d8d-4ab9-a45c-randElem</ns1:EnvelopeID>
<ns1:Username>Test Signer</ns1:Username>
<ns1:Email>Guest</ns1:Email>
<ns1:AuthenticationAssertion>
<ns1:AssertionID>175</ns1:AssertionID>
<ns1:AuthenticationInstant>2013-09-18T00:00:00.00</ns1:AuthenticationInstant>
<ns1:AuthenticationMethod>Email</ns1:AuthenticationMethod>
<ns1:SecurityDomain>192.168.0.43</ns1:SecurityDomain></ns1:AuthenticationAssertion>
<ns1:ClientURLs>
<ns1:OnSigningComplete>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSigningComplete</ns1:OnSigningComplete>
<ns1:OnViewingComplete>https://YourApp.com/DocuSignCallback.html?
envelopeId=YourEnvelopeId&event=OnViewingComplete</ns1:OnViewingComplete>
<ns1:OnCancel>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnCancel</ns1:OnCancel>
<ns1:OnDecline>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnDecline</ns1:OnDecline>
<ns1:OnSessionTimeout>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSessionTimeout</ns1:OnSessionTimeout>
<ns1:OnTTLExpired>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnTTLExpired</ns1:OnTTLExpired>
<ns1:OnException>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnException</ns1:OnException>
<ns1:OnAccessCodeFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnAccessCodeFailed</ns1:OnAccessCodeFailed>
<ns1:OnIdCheckFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnIdCheckFailed</ns1:OnIdCheckFailed>
<ns1:OnFaxPending>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnFaxPending</ns1:OnFaxPending>
</ns1:ClientURLs>
</ns1:RequestRecipientToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

That error indicates that the DocuSign user credentials you're providing in the request to authenticate the API call are not valid. The code you included in this post is irrelevant, really, as any API call would result in this error if either the username or password you're providing to authenticate the request is invalid.
If you haven't already done so, I'd suggest that you produce a trace of the full XML Request (i.e., including headers) to closely examine the authentication credentials that you're providing in the request. The best way to troubleshoot issues like this is to examine what's going over the wire (rather than trying to troubleshoot code that's producing what's going over the wire) -- once the issue in the XML is identified, it should be easy to fix in the code.

Regarding the "username or password invalid" error -- it might be caused by the fact that your not including your Integrator Key within Username. From page 18 of the DocuSign SOAP API Guide (http://www.docusign.com/sites/default/files/DocuSignAPI_Guide.pdf):
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 ]”. Example format:
<wsse:Username>[Integrator Key]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>
The Integrator Key must be included in all API requests, as DocuSign requires it in order to identify the integrating application.

Related

DocuSign.eSign.Client.ApiException {"error":"consent_required"}" / Response Type Not Supported when attempting to grant consent

I tried to receive a token with the code below. Unfortunatelly I get the error:
DocuSign.eSign.Client.ApiException
HResult=0x80131500
Nachricht = Error while requesting server, received a non successful HTTP code with response Body: {"error":"consent_required"}
I tried with set TLS 12 and without. We run it in dev mode with base path https://demo.docusign.net/restapi
and oAuthBasePath =account-d.docusign.com
I tried also to set the consens manually with the URL below. But I receive the error in (Login Window) invalid Authorization: RequestType is not supported.
https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature%20impersonation&client_id=a5ed47d5-xxxx-xxxx-8a19-756da64391de&redirect_uri=https://www.docusign.com
Is the something wrong with my account setting?
byte[] privateKey=DSHelper.ReadFileContent(DSHelper.PrepareFullPrivateKeyFilePath(privateKeyFilename));
var scopes = new List<string>
{
"signature",
"impersonation",
};
var basePath = ApiClient.Production_REST_BasePath;
var oAuthBasePath = OAuth.Production_OAuth_BasePath;
if (!production)
{
basePath = ApiClient.Demo_REST_BasePath;
oAuthBasePath = OAuth.Demo_OAuth_BasePath;
}
var _apiClient = new ApiClient(basePath);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var authToken = _apiClient.RequestJWTUserToken(
clientId,
ImpersonatedUserId,
oAuthBasePath,
privateKey,
1,
scopes);
I found the solution. instead of reponse_type= code I have to use token
What response_type is supported for an integration key depends on how the key is configured. In the Authentication section of the key's configuration panel, Auth Code Grant allows the response type of code, while Implicit Grant allows the response type of token.
DocuSign's authentication docs assume you have "Auth Code Grant" selected, but either is technically acceptable to allow JWT consent.

set messagettl of a message in Azure Queue using python

I'm trying to post a message to azure queue service using python3 by making a POST request and specifying messagettl to -1 which indicates the message does not expire. In the doc https://learn.microsoft.com/en-us/rest/api/storageservices/put-message I have to specify the Authorization key and Date which indicates the time at which the response was initiated (both parameters are required), and the body must be an XML, here what I did:
url = "https://MyStorageAccountName.queue.core.windows.net/MyQueueName?messagettl=-1"
xml = """<?xml version='1.0' encoding='utf-8'?>
<QueueMessage>
<MessageText>First message</MessageText>
</QueueMessage> """
headers = {'Content-Type': 'application/xml',
'Authorization' : 'SharedKey MyStorageAccountName:MyKey1....==',
'Date' : str(datetime.utcnow())}
print(requests.post(url, data=xml, headers=headers).text)
And the response is an error:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:44d1fd4c-c003-001d-215...000
Time:2020-11-20T15:39:10.9730253Z</Message>
<AuthenticationErrorDetail>The Date header in the request is incorrect.</AuthenticationErrorDetail>
</Error>
which piece of the puzzle I am missing?
UPDATE:
In headers I fixed the issue by replacing str(datetime.utcnow()) with format_date_time(mktime(datetime.now().timetuple())) and fixed the related date error, but I have a new error and don't know how to sign my key:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:359305a5-a003-0034...
Time:2020-11-20T15:59:12.4611176Z</Message>
<AuthenticationErrorDetail>The MAC signature found in the HTTP request 'HACSNj/4PwH...MyKey...YJQ==' is not the same as any computed signature. Server used following string to sign: 'POST
application/xml
Fri, 20 Nov 2020 15:59:09 GMT
/MystorageAccount/MyQueueName'.</AuthenticationErrorDetail>
</Error>
I think using python SDK to do this is much easier, just try the code below:
from azure.storage.queue import QueueClient
connectionString = "<storage account connection string>"
queueName = "<queue name>"
queueClient = QueueClient.from_connection_string(connectionString, queueName)
queueClient.send_message(content = 'hello sdk', time_to_live=-1)
Result:
For info about python queue client sdk, just refer to this doc.

DocuSign API - C# console application - RequestJWTUserToken - error "consent_required"

I need advice on what I'm doing wrong. I'm calling the following block of code from a console application in C#:
string path = # "C:\Temp\private.key";
ApiClient apiClient = new ApiClient();
var authToken = apiClient.RequestJWTUserToken (
"11383d14-8c83-4c61-ab4f-99d5d19bd2dd",
"476205fe-9d1a-46be-95e3-6873315ce3a9",
"account-d.docusign.com",
File.ReadAllBytes(path),
1,
new List<string>
{
"signature",
"impersonation"
});
Error is: "consent_required"
I have authentication set to "Authorization Code Grant".
What's wrong in the parameters or settings?
Thank you
This is right, you need to obtain consent and we have plenty of documentation about it.
https://www.docusign.com/blog/developers/oauth-jwt-granting-consent
https://developers.docusign.com/platform/auth/jwt/jwt-get-token/
If still you feel some documentation is not clear about JWT consent - can you let me know which one?

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