Skip to content

GCS private key not working #5

Description

@JClishe

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:

  1. First, I copied my entire private key into this field (removing all \n newlines) and receive an "incorrect padding" error.

  2. 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)

  1. 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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions