Error: Authorization failed when trying to connect to Local Docker Setup

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)

@orchid010203

It seems that you are encountering an “Authorization failed” error when trying to connect to your local Docker setup of Aspose.Words Cloud. The error message indicates that the username or password you provided is incorrect.

Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Check Username and Password: Ensure that the username and password you are using in your code match exactly with what you set in the Docker container. In your Docker run command, you specified:

    -e User="random" -e Password="12312312312"
    

    Make sure you are using “random” as the username and “12312312312” as the password in your API calls.

  2. Trial Mode Considerations: If you are trying to evaluate Aspose in trial mode, ensure that you have configured the Docker container correctly for trial usage. Some configurations may require a license file or specific settings to be set for trial mode.

  3. Debugging Logs: If you have access to the logs from the Docker container, enable debug logging to get more detailed information about the authentication process. This can help identify if the credentials are being received correctly.

  4. API Endpoint: Verify that you are using the correct API endpoint. In your code, you are connecting to http://localhost:8089, which should be correct if your Docker container is running and mapped properly.

  5. Testing with Curl or Postman: As a further test, you can try to authenticate using a tool like Curl or Postman to see if you can successfully obtain a token with the same credentials. This can help isolate whether the issue is with your code or the Docker setup.

If you continue to experience issues, consider checking the community forums or documentation for additional troubleshooting tips related to authentication errors in the Aspose.Words Cloud Docker setup.

If you have any further questions or need additional assistance, feel free to ask!

Sorry
Found a working solution following this
https://forum.aspose.cloud/t/self-hosting-words-cloud-configure-aws-s3-as-storage-via-docker-container/22956/7

Great to hear you resolved this issue.