Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCS private key not working #5

Open
JClishe opened this issue Feb 13, 2025 · 0 comments
Open

GCS private key not working #5

JClishe opened this issue Feb 13, 2025 · 0 comments

Comments

@JClishe
Copy link

JClishe commented Feb 13, 2025

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant