Hi! In one of my steps, I need to autenticated on an API, and I don’t want to expose the authentication, so my idea was to put the authentication curl on an environment variable so I have something like this:
on my config.yml file:
- run:
name: Send Report
when: always
command: |
token= $API_TOKEN
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data @"merged-test-results.json" "http://example.com/api/import/report/"
My environment variable is the authentication curl like this:
curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"XXXXXXXXXXX\",\"client_secret\": \"XXXXXXXXX\" }
" "http://example.com/api/v1/authenticate"| tr -d '"'
When I run this on bash works fine, but running on Circle CI I got this error:
#!/bin/bash -eo pipefail
token= $API_TOKEN
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data @"merged-test-results.json" "http://example.com/api/import/report/"
curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: \"client_id\"
curl: (6) Could not resolve host: \"XXXXXXXXXXXXXXXXXX\",\"client_secret\"
curl: (6) Could not resolve host: \"XXXXXXXXXXXXXXXXXXXXXXXXXXXX\"
curl: (3) unmatched close brace/bracket in URL position 1:
}
^
Exited with code exit status 6
CircleCI received exit code 6
Am I doing something wrong? What is the correct way of a curl like this on a variable?