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.
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);
}