Skip to main content

import axios from "axios";

import docusign from "docusign-esign";

import fs from "fs";

import path from "path";

 

const getAccessToken = async () => {

  const apiClient = new docusign.ApiClient();

  apiClient.setOAuthBasePath("account-d.docusign.com");

 

  const privateKey = fs.readFileSync(

    path.join(process.cwd(), process.env.NEXT_PUBLIC_SIGNUP_CLIENT_SECRET || "")

  );

  const response = await apiClient.requestJWTUserToken(

    process.env.NEXT_PUBLIC_SIGNUP_CLIENT_ID,

    process.env.NEXT_PUBLIC_SIGNUP_USER_ID,

    D"signature"],

    privateKey,

    3600

  );

 

  return response.body.access_token;

};

where i can find these issues? 
tried to use this, but have error AUTHORIZATION_INVALID_TOKEN

 

the scopes should be impersonation signature for JWT.

 

FreeLink/甫连信息

🌍 Docusign Partner | Partner Profile

🏆 Docusign 2024 APAC Reseller Growth Partner of the Year

🌟 The only Docusign Partner globally certified as both a Certified eSignature Administrator and eSignature Technical Consultant.

📊 Docusign Community Leaderboard Top 5 contributor.

🚀 Expertise in Docusign integrations with on-premises systems for leading enterprises across various industries.


Regarding the AUTHORIZATION_INVALID_TOKEN error, it occurs when the invalid access token (expired or malformed) is used to call the eSignature REST API. Please refer to the below link for more information about this error: https://developers.docusign.com/docs/esign-rest-api/esign101/error-codes/troubleshooting-common-errors/#authorization-invalid-token

I've reviewed the code but I wonder whether you import the RSA private key in the below line of the code as it seems you import the client secret.

 const privateKey = fs.readFileSync(
 path.join(process.cwd(), process.env.NEXT_PUBLIC_SIGNUP_CLIENT_SECRET || "")
 );

If you don't import the RSA private key, please generate it on Docusign Portal > Admin > Apps and Keys > Actions > Edit > Generate RSA and then import it using the above code.


Reply