Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error while trying to authenticate gcloud with json

So I have the gcloud docker image and want to use gcloud through the image, but I need to authenticate and I'm getting this error.

ERROR: (gcloud.auth.activate-service-account) Could not read json file credentials.json: Invalid control character

and these are the commands I'm using

echo -n "$GOOGLE_TOKEN" > /tmp/credentials.json - cat /tmp/credentials.json - gcloud auth activate-service-account --key-file=/tmp/credentials.json

and the service account json does work on other apps.

like image 206
Hannan Rhodes Avatar asked Oct 21 '25 04:10

Hannan Rhodes


1 Answers

"echo" is not portable. In some cases it does \X escape processing by default. It depends on the system and/or shell variant and/or shell release. Use printf instead of "echo -n ...":

printf '%s' "$GOOGLE_TOKEN"

like image 72
Glenn Fowler Avatar answered Oct 23 '25 19:10

Glenn Fowler