Blog
Home/

Trending Topics: Latest from our forums (September 2021)

Inbar Gazit
Inbar GazitSr. Manager, Developer Content
Summary3 min read

See how our most popular recent threads on StackOverflow can help you solve your own development issues.

    • Additional resources

    Table of contents

    Here are some of the latest popular questions that the Docusign developers community asked on Stack Overflow in the month of September 2021. You too can ask questions by using the tag docusignapi in Stack Overflow.

    Thread: Generate JSON Web Token (RS256) to access Docusign using Google Apps Script

    https://stackoverflow.com/questions/69133483/

    Summary: The developer is trying to obtain access tokens using JWT and is running the following code:

    function createJWT(){
      const header = {
        alg: 'RS256',
        typ: 'JWT',
      };
    
      const now = Date.now();
      const expires = new Date(now);
      expires.setHours(expires.getHours() + 1);
      const payload = {
        exp: Math.round(expires.getTime() / 1000),
        iat: Math.round(now / 1000),
        iss: "integrator key",
        sub: "user id",
        aud: "url",
        scope: "scopes"
      };
    
      var toSign = Utilities.base64EncodeWebSafe(JSON.stringify(header)) + '.' + Utilities.base64EncodeWebSafe(JSON.stringify(payload));
      toSign = toSign.replace(/=+$/, '');
    
      var privateKey = "-----BEGIN RSA PRIVATE KEY-----<private key here>-----END RSA PRIVATE KEY-----";
    
      const signatureBytes = Utilities.computeRsaSha256Signature(
        toSign,
        privateKey
      );
      const signature = Utilities.base64EncodeWebSafe(signatureBytes);
    
      return toSign + '.' + signature;
    }
    </private>
    

    They get the Exception: Invalid argument: key returned by Utilities.computeRsaSha256Signature().

    Answer: There are two separate issues here that need to be addressed:

    First, the line Utilities.base64EncodeWebSafe() should be replaced with Utilities.base64Encode() and the toSign.replace(...) be removed. 

    Second, the RSA private key is a text file whose first line is BEGIN PRIVATE KEY, not BEGIN RSA PRIVATE KEY. This is a different type of RSA private key and cannot be used with this library.

    Alternatively, the developer can use the Docusign eSignature Node SDK, which includes built-in JWT methods that can be used to obtain access tokens.

    Thread: Documents in Composite Template error in tabs

    https://stackoverflow.com/questions/69200877/

    Summary: This developer is using composite templates and is not seeing all the tabs that they expected to see in the envelope, which was built out of two templates.

    Answer: There are two potential issues here. The ServerTemplate elements in the request must include matching roleName properties that are identical to the ones defined in the templates for the recipients. These recipients have tabs that are not showing. The tabs that were manually added to the composite template are not showing because they did not include any positioning information. Tabs must be positioned either by fixed positioning (using the pageNumber, xPosition, and yPosition properties) or by using anchor strings.

    https://stackoverflow.com/questions/69216970/

    Summary: The developer is interested in sending an envelope with requests for signature for two signers. They require one signer to sign only after the other has finished.

    Answer: To do that, you set up two recipients in your envelope with signing elements for each. The important thing is to set the routingOrder such that your first signer is “1” and the second signer is “2”. This guarantees that the second signer will not get the email notification to request their signature until the first signer finishes signing the envelope.

    Additional resources

    Inbar Gazit
    Inbar GazitSr. Manager, Developer Content

    Inbar Gazit has been with Docusign since 2013 in various engineering roles. Since 2019 he has focused on developer content. Inbar works on code examples including the launchers, available on GitHub in eight languages, and helps build sample apps showcasing the various Docusign APIs. He is also active on StackOverflow, answering your questions. Inbar can be reached at inbar.gazit@docusign.com.

    More posts from this author

    Related posts

    • Developers

      What Are API Services? Benefits & Uses

      Docusign Contributor
    • Fast-Track Your Extension Apps with Reference Implementations

      Karissa Jacobsen
      Karissa Jacobsen
    • Paige Rossi
      Paige Rossi

    Fast-Track Your Extension Apps with Reference Implementations

    Karissa Jacobsen
    Karissa Jacobsen
    Paige Rossi
    Paige Rossi

    Discover what's new with Docusign IAM or start with eSignature for free

    Explore Docusign IAMTry eSignature for Free
    Person smiling while presenting