1
votes

I am working on a C# project trying to generate a DocuSign envelope.

As a starting point, I am trying to work through a DocuSign JWT example at https://github.com/docusign/eg-01-csharp-jwt-framework.

I went to the URL that the console application told me to go to. https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature impersonation&client_id=CLIENTID9&redirect_uri=https://www.docusign.com

After that process was complete, I did get an access_token returned to me in the URL.

I got the following token, I removed part of it with a (…) https://www.docusign.com/#access_token=eyJ0e...&expires_in=28800&token_type=bearer

What should I do next to generate an envelope and get a signing URL?

2

2 Answers

1
votes

Chad, The code example you referenced was a good starting point in how to use JWT to obtain an access token. keep that handy. An access token can now be used to call any eSignature API endpoint. Here is a different set of code examples that would show you many things you can do with the API:

https://github.com/docusign/eg-03-csharp-auth-code-grant-core

Specifically generating an envelope for embedded signing is here:

https://github.com/docusign/eg-03-csharp-auth-code-grant-core/blob/master/eg-03-csharp-auth-code-grant-core/Controllers/Eg001EmbeddedSigningController.cs

Just tweak the part of the code that uses the token to use the token from your other code:

var config = new Configuration(new ApiClient(basePath));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
0
votes

The URL presented to you by the eg-01 JWT example has two effects, but, in this case, you only want one:

  • The URL starts the Authorization Code Grant flow for your IK. As part of this flow you are asked to authenticate with DocuSign and you are asked to grant consent for the scopes the application requests for its client_id.

    This is the effect that you want. Your original problem was that you had not (yet) granted consent and the JWT Grant request therefore failed.

    If you now re-run the eg-01 JWT example, it should complete successfully.

  • Effect 2: you'll get back a URL that includes an authorization code.

    This effect--including the auth code, etc. should be IGNORED. It has nothing to do with your application since you're using JWT Grant.

    If you were using Authorization Code Grant, then you'd use the returned authorization code. But you're not, so don't.