Get Authentication Token From The DocuSign (Part-2)

We set up the new API project in .NET Core in the previous article. We’ll continue working on the next job here. Part 1 of this post can be found by clicking here. You can read my Introduction To DocuSign article to learn about DocuSign’s apps and keys.

Step 5: Add the DocuSign API Controller.

Step 6: Add a Services folder and add interface class IDocuSignService and DocuSignService in it.

  • Register the services in the Program.cs file(.net 6) or Startup.ts file(less than .net 5)

Step 7: Define the method in the IDocuSignService interface.

public interface IDocuSignService
    Task<string> GetTokenFromDocuSign();

Step 8: Implement the method in the DocuSignService class.

public class DocuSignService : IDocuSignService
    private readonly IConfiguration _configuration;
    public DocuSignService(IConfiguration configuration) 
        _configuration = configuration; 

    public Task<string> GetTokenFromDocuSign()
        var accessToken = string.Empty;
            ApiClient _apiClient = new ApiClient();

            OAuth.OAuthToken authToken = _apiClient.RequestJWTUserToken(
                  new List<string> { OAuth.Scope_SIGNATURE, OAuth.Scope_IMPERSONATION });
            accessToken = authToken.access_token;
        catch (Exception ex)
            accessToken = ex.Message;
        return Task.FromResult(accessToken);

Step 9: Finally initalize the method into the DocuSignController.

public async Task<IActionResult> GetTokenFromDocuSign()
    var apiResponse = await _docuSignService.GetTokenFromDocuSign();
    return new JsonResult(apiResponse);

Following these procedures will give you the string that represents your DocuSign access token.

What’s Next:

In the next article, we will generate a JSON file in DocuSign. We will upload the simple PDF file in the templates, and add some fields and a signature box then DocuSign will give the JSON file. You can read how to generate a JSON document file in DocuSign by clicking here

Related Articles:

Getting Started With The DocuSign

Get Authentication Token From The DocuSign (Part-1)

How To Create JSON Document File For Signature In DocuSign

Send Document To Other Users For Signature In DocuSign

Get Document Data From DocuSign

Download Document From DocuSign

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories