Skip to main content
Participant
October 17, 2023
Question

"The provided token is malformed or otherwise invalid." error returned when using CreatePDFOperation

  • October 17, 2023
  • 0 replies
  • 222 views

See the below exception details:


Exception Details: Adobe.PDFServicesSDK.exception.ServiceApiException: The provided token is malformed or otherwise invalid.

 

I've double-checked and the credentials are correct based on what was provided. What am I missing?

 

Code:

Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()
.WithClientId("*********************************")
.WithClientSecret("******************************")
.Build();

 

ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 

//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.Create(credentials);
CreatePDFOperation createPdfOperation = CreatePDFOperation.CreateNew();

// Set operation input from a source file.
FileRef source = FileRef.CreateFromLocalFile(file);
createPdfOperation.SetInput(source);

// Execute the operation.
FileRef result = createPdfOperation.Execute(executionContext);

exported_filepath = Path.Combine(export_path, export_filename);
// Save the result to the specified location.
result.SaveAs(exported_filepath);

    This topic has been closed for replies.