Hi
I’ve tried using the following to connect to api.aspose.cloud/v4.0. I didn’t have any issue
However, when I tried it with the local docker setup created from the image provided by apose.cloud on dockerhub i kept getting Authentication Error.
Code:
import { ConvertDocumentRequest, WordsApi } from "asposewordscloud";
import { createReadStream } from "fs";
import fs from "fs";
// Start README example
// create API instance (baseUrl is optional)
const wordsApi = new WordsApi(
"e8110c74-====================",
"0e7632======================",
"http://localhost:8089",
true
);
// upload file to the Aspose cloud
const convertDocument = new ConvertDocumentRequest();
convertDocument.document = createReadStream("Test.docx");
convertDocument.format = "html";
wordsApi
.convertDocument(convertDocument)
.then((_uploadResult) => {
// save the file as pdf in the cloud
fs.writeFileSync("output.html", _uploadResult.body);
console.log("HTML file saved as output.html");
})
.catch(function (_err) {
console.log("Error");
console.log(_err);
// handle uploadFile request error
});
// End README example
Docker Run Command
docker run --name AsposeWordsCloud -p 8089:80 -e User="random" -e Password="12312312312" aspose/words-cloud
Error
{
"request": {
"debugId": 1,
"uri": "http://localhost:8089/v4.0/words/connect/token",
"method": "POST",
"headers": {
"x-aspose-client": "nodejs sdk",
"x-aspose-client-version": "25.3",
"host": "localhost:8089",
"content-type": "application/x-www-form-urlencoded",
"accept": "application/json",
"content-length": 123
},
"body": "grant_type=client_credentials&client_id=xxxxx&client_secret=xxxxxxb"
}
}
{
"response": {
"debugId": 1,
"headers": {
"content-length": "52",
"content-type": "application/json; charset=utf-8",
"date": "Fri, 28 Mar 2025 10:04:48 GMT",
"server": "Kestrel",
"api-supported-versions": "4.0"
},
"statusCode": 400,
"body": {
"message": "Username or password is incorrect"
}
}
}
Error
Error: Authorization failed
at D:\Project\doc-converter-cloud\node_modules\asposewordscloud\dist\internal\requestHelper.js:149:23
at Generator.throw (<anonymous>)
at rejected (D:\Project\doc-converter-cloud\node_modules\asposewordscloud\dist\internal\requestHelper.js:32:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)