Expand my Community achievements bar.

SOLVED

Can anyone help me convert this node example to an OAuth login ?

Avatar

Level 1

We have been told to migrate our login credentials to use Oauth but i cannot find an example of the code to use. Can anyone help me convert this code to Oauth.

Example Node Code :

const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');
 try {
   // Initial setup, create credentials instance.
   const credentials =  PDFServicesSdk.Credentials
       .serviceAccountCredentialsBuilder()
       .fromFile("pdfservices-api-credentials.json")
       .build();
   
  const clientConfig = PDFServicesSdk.ClientConfig
       .clientConfigBuilder()
       .withConnectTimeout(1200000)
       .withReadTimeout(600000)
       .build();

   //Create an ExecutionContext using credentials and create a new operation instance.
   const executionContext = PDFServicesSdk.ExecutionContext.create(credentials, clientConfig),
       exportPDF = PDFServicesSdk.ExportPDF,
       exportPdfOperation = exportPDF.Operation.createNew(exportPDF.SupportedTargetFormats.XLSX);

   // Set operation input from a source file
   const input = PDFServicesSdk.FileRef.createFromLocalFile('03e12918-cf31-408b-93c6-6af0abeb6580.pdf');
   exportPdfOperation.setInput(input);



   // Execute the operation and Save the result to the specified location.
   exportPdfOperation.execute(executionContext)
       .then(result => result.saveAsFile('output/03e12918-cf31-408b-93c6-6af0abeb6580.csv'))
       .catch(err => {
           if(err instanceof PDFServicesSdk.Error.ServiceApiError
               || err instanceof PDFServicesSdk.Error.ServiceUsageError) {
               console.log('Exception encountered while executing operation', err);
           } else {
               console.log('Exception encountered while executing operation', err);
           }
       });
       console.log("")
 } catch (err) {
   console.log('Exception encountered while executing operation', err);
 }
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion
1 Reply

Avatar

Correct answer by
Community Advisor and Adobe Champion