I'm trying to encrypt/decrypt files with Google Cloud KMS. Encrypting/decrypting with the gcloud command works perfectly. But now I need to pass this to other users who don't/should not have acces to my gcloud account. They should be able to decrypt and encrypt with the curl command.
I've tried: - En/Decrypting with the gcloud command. Works perfectly - En/Decrypting on an google cloud compute engine. Works perfectly - En/Decrypting with curl. Does not work.
base64 appsettings.json.encrypted -w 0 > appsettings.json.encrypted.base
curl -v "https://cloudkms.googleapis.com/v1/projects/projectid/locations/global/keyRings/test/cryptoKeys/quickstart:encrypt" -d "{\"plaintext\":\"$(cat appsettings.json.encrypted.base)\"}" -H "Authorization:Bearer API KEY" -H "Content-Type: application/json"
I expect to get the encrypted text.
Right now I'm getting:
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}