Cloud Storage file convert task in CloudConvert returns "message":"Unauthenticated

1.4k views Asked by At

I have excel xls files in GCS which I am trying to convert to csv using cloudconvert API. As such I am using the job builder in v2 API to create the necessary curl for extracting file from GCS, transformation and upload. I have provided the required key, service account, permission to the service account and project details. Issue is whenever I use the curl formed from CLI I receive the following error -

{"message":"Unauthenticated.","code":"UNAUTHENTICATED"}

Request sample:

curl -X POST "https://api.cloudconvert.com/v2/jobs" \     
-H "Authorization: Bearer API_KEY" \     
-H "Content-type: application/json" \     
-d '{     
      "tasks": {
        "import-1": {             
          "operation": "import/google-cloud-storage",             
          "project_id": "sxxxxxx",             
          "bucket": "testxxxxxx",             
          "client_email": "[email protected]",             
          "file": "testconvert.xls",             
          "private_key": "-----BEGIN PRIVATE KEY-----\nMII--xxxxx--kQzfSa\n-----END PRIVATE KEY-----\n"         
        }     
      } 
    }'

Any pointers to what could be wrong is appreciated. I could not find reference to the error to provide a solution anywhere

1

There are 1 answers

1
Donnald Cucharo On BEST ANSWER

According to CloudConvert API document:

To authenticate requests, you need to create an API key. API keys do not expire unless you revoke them. Requests are authenticated using the Authorization: Bearer API_KEY header.

When creating an API key, make sure the following scopes are at least checked:

  • task.read
  • task.write

From your provided sample requests, it looks like you provided the complete details except the Authorization header.

Your Auth header should then look like this:

-H "Authorization: Bearer eyJ0exxxxxxxx"