GenAI-Showcase
GenAI-Showcase copied to clipboard
Issue with uploading image to gcs
I keep running into the following error:
RefreshError Traceback (most recent call last)
16 frames /usr/local/lib/python3.11/dist-packages/google/auth/compute_engine/credentials.py in refresh(self, request) 130 except exceptions.TransportError as caught_exc: 131 new_exc = exceptions.RefreshError(caught_exc) --> 132 raise new_exc from caught_exc 133 134 @property
RefreshError: ("Failed to retrieve http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true from the Google Compute Engine metadata service. Status: 404 Response:\nb''", <google.auth.transport.requests._Response object at 0x7b5c79273010>)
I tried to resolve by setting up a service key under a new project and ran the following:
from google.colab import files
uploaded = files.upload() # Upload your JSON key file
import os
from google.oauth2 import service_account
from google.cloud import storage
# Replace with your actual file name
SERVICE_ACCOUNT_FILE = "your-key-file.json"
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE
)
# Now initialize the GCS client with credentials
gcs_client = storage.Client(project=GCS_PROJECT)
gcs_bucket = gcs_client.bucket(GCS_BUCKET)
Still get the same error