-
Notifications
You must be signed in to change notification settings - Fork 24
Description
I'm trying to implement a GCS bucket for element storage and the APP_GCS_PRIVATE_KEY variable isn't working. I've tried multiple approaches:
-
First, I copied my entire private key into this field (removing all \n newlines) and receive an "incorrect padding" error.
-
Next, I encoded my private key using the script below and pasted my encoded key into APP_GCS_PRIVATE_KEY and receive the error "MalformedError("No key could be detected.")
google.auth.exceptions.MalformedError: No key could be detected."
import base64
private_key = "-----BEGIN PRIVATE KEY-----[My key] ----END PRIVATE KEY-----"
encoded_key = base64.b64encode(private_key.encode('utf-8')).decode('utf-8')
print(encoded_key)
- Finally, I base64 encoded my entire service account json file using the script below and still receive the same "...no key could be detected" error.
import base64
import json
with open('service_account_key.json', 'r') as f:
service_account_info = json.load(f)
processed_info = {
"type": service_account_info["type"],
"project_id": service_account_info["project_id"],
"private_key_id": service_account_info["private_key_id"],
# Process the private key:
"private_key": service_account_info["private_key"].replace("\n", "").strip(),
"client_email": service_account_info["client_email"],
"client_id": service_account_info["client_id"],
"auth_uri": service_account_info["auth_uri"],
"token_uri": service_account_info["token_uri"],
"auth_provider_x509_cert_url": service_account_info["auth_provider_x509_cert_url"],
"client_x509_cert_url": service_account_info["client_x509_cert_url"]
}
processed_json_string = json.dumps(processed_info)
encoded_credentials = base64.b64encode(processed_json_string.encode('utf-8')).decode('utf-8')
print(encoded_credentials)