Generate a signature token for viewing private documents

CloudPDF is using tokens for authentication of private documents. Unless you change the security settings of a document you need to generate a token in order to access it. Your backend generates a token and on the client you will add it to the CloudPDF viewer. The viewer will send the token to the CloudPDF server which verifies if the token is valid. If the token is valid it will send the document information and the document will be visible.

import { CloudPDF } from '@openbook/cloudpdf-node'
const cloudPDF = new CloudPDF({
accessKey: 'Your access key',
accessSecret: 'Your secret key',
cloudName: 'Your cloud name'
const key = cloudPDF.signDocument({
type: 'get-document',
documentId: 'your document id',
exp: (new Date().getTime() + 60 * 60 * 1000)/1000,
download: false
  • type in this case always have to be get-document
  • documentId your document ID. where to find your document id?
  • exp token expiration date in UNIX timestamp format
  • download if set to false the document is not downloadable. If set to true, the document is downloadable