0

Using the VS2019 Docusign Extension. I chose WebAPI and JWT Authentication. A sample project was generated.

I inserted one line of code to call in the sample WeatherForecastController's Get method: JWTAuth.AuthenticateWithJWT();

All of the expected params are being picked up from the app.config file but I am getting the Error: 'Unexpected PEM type':

enter image description here

Here is what my app.config files looks like that was generated by the Docusign Extension.

enter image description here

And one final piece of info: enter image description here

In the docusign portal, I have tried setting the Authentication type to both "Code Grant" or "Implicit". The one that I actually want it JWT Authentication but that is not an explicit option, so which one should I be using for JWT Auth?

Any help would be greatly appreciated.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23

3 Answers3

0

Can you try with Encoding.ASCII.GetBytes()?

Nima
  • 392
  • 1
  • 4
  • try Encoding.ASCII.GetBytes(), where? To get the RSAKey? – Dennis A. Landi Mar 05 '21 at 20:14
  • replace Encoding.UTF8.GetBytes() with Encoding.ASCII.GetBytes() – Nima Mar 06 '21 at 01:30
  • Encoding.ASCII.GetBytes() seems to have worked but now. I am getting the "consent_required." I see Larry's post about granting consent, but I see no way to actually pass in the redirect URL with this call to Request a JWT Token. Does anyone have a working example of how to do this with just a WebAPI controller and not MVC? The documentation is too fragmented. And the generated project is inadequate, in my opinion. – Dennis A. Landi Mar 07 '21 at 23:07
0

not sure if you generated RSA keypair in the Apps and Keys page for that IK. You should have done so and then copy/pasted the key directly to private.key file (using notepad, not VS). The file has to be exactly as is from the DocuSign portal to avoid this error. (the lines -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- are part of the key, cannot be removed, everything is required)

You can also try to replace:

Encoding.UTF8.GetBytes()

with

System.IO.File.ReadAllBytes()

Videos related to using C# with DocuSign:

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • I have used the "Quick Start" Process on the DocuSign Developer page, and it will generate all the security credentials and RSA and save the generated project to a zip which the Developer can download and run. What is generated, is an Asp.Net Core MVC project. In this project the RSA Key is saved to the project as a file. This project works. But I want a WebAPI version, not using MVC Controllers. This differs from the WebAPI Project that is generated with the Docusign Extension that I already described. Try it yourself, please. User the Docusign Extension to create a WebAPI Project. – Dennis A. Landi Mar 05 '21 at 21:06
  • It works just fine for me. The issue is that you don't have the full RSA key. You removed the lines -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- It's all required. I'll update my answer – Inbar Gazit Mar 09 '21 at 15:25
  • I tried with the lines as well, and it didn't work. But, I used your suggestion of loading the external file with System.IO.File.ReadAllBytes(), and that did work, but I encountered other errors. And so I have fallen back to the MVC project that is generated on the DocuSign developer quick start page. That works. Inbar, it would be really helpful if you could upload a youtube video of all the steps you are using to a) get an an access token, and b) execute the embedded signing ceremony using just the web api controller. Thanks! – Dennis A. Landi Mar 10 '21 at 16:54
  • Here is a fix to the root of this problem: https://stackoverflow.com/questions/66919340/docusign-net-sdk-esign-dll-dealing-with-changes-in-docusign-config-params-r/66919341#66919341 – Dennis A. Landi Apr 02 '21 at 12:31
0

Here is a fix to the root of this question, which is that the key-file-as-string-config-param works in Esign 4.1.1 but not in version 5.2:

DocuSign .NET SDK - Esign DLL - Dealing with changes in Docusign Config Params regarding Error: 'Unexpected PEM type'