Skip to main content
Question

Want to Integrate docusign-esign in SPFx Webpart

  • November 5, 2025
  • 1 reply
  • 15 views

Hello there,

I got stuck when I am trying to integrate docusign-esign node module in my spfx webpart.

  1. I’ve created a new spfx webpart
  2. I’ve installed docusign-esign module in the working directory. (My webpart package.json has the following entry…   "docusign-esign": "^8.5.0

Error When I gulp serve - I am getting the following , one of so many.: 'dist':
./node_modules/docusign-esign/src/index.js: Module not found: Error: Can't resolve 'ApiClient' in 'C:\Phani\Custom Development\PembinaApprovalsDashboard\PembinaApprovalsDashboard\node_modules\docusign-esign\src'
Did you mean './ApiClient'?

 

On init of my webpart, I’ve the following code.

try

      {

        let dsApiClient = new docusign.ApiClient();

        dsApiClient.setOAuthBasePath(this.DOCUSIGN_OAUTH_BASE_PATH);

        // Use Buffer.from for DocuSign API compatibility

        const privateKeyBuffer = Buffer.from(DOCUSIGN_RSA_PRIVATE_KEY, 'utf8');

        const results = await dsApiClient.requestJWTUserToken(

          this.DOCUSIGN_INTEGRATION_KEY,

          this.DOCUSIGN_USER_ID,

          this.DOCUSIGN_SCOPES,

          privateKeyBuffer,

          3600

        );

      this.accessToken = results.body.access_token;

      console.log("DocuSign Access Token: " + this.accessToken);

    }

    catch (error) {

      if (error.response && error.response.body) {

        const errorBody = JSON.parse(error.response.body);

        if (errorBody.error === 'consent_required') {

          console.log('Consent is required. Please visit the following URL to grant consent:');

          console.log(this.consentUrl);

        } else {

          console.error('Error obtaining JWT user token:', errorBody);

        }

      }

    }

 

 

1 reply

Forum|alt.badge.img+8
  • Docusign Employee
  • 85 replies
  • November 6, 2025

Please check this GitHub issue as the same error has occurred with a different user in the past: https://github.com/docusign/docusign-esign-node-client/issues/332