google-cloud-storagecloudconvert

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


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": "testxxxxxxx@xxxxxxxx.iam.gserviceaccount.com",             
          "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


Solution

  • 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:

    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"