Hi everyone,
I'm trying to set up Google Cloud's Application Default Credentials (ADC) for my Django project on PythonAnywhere, but I keep encountering the following error:
Error creating story: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
What I've Done So Far:
- Created a Service Account:
- I created a service account in Google Cloud and downloaded the JSON key file.
-
The file is stored at:
/home/footageflow/helloworld2003-754c20cfa98d.json
. -
Set the
GOOGLE_APPLICATION_CREDENTIALS
Environment Variable: - I added the following line to my
.bashrc
file:bash export GOOGLE_APPLICATION_CREDENTIALS="/home/footageflow/helloworld2003-754c20cfa98d.json"
-
I then ran
source ~/.bashrc
to reload it. -
Tried Programmatic Credentials:
-
I also tried explicitly setting the environment variable in my Django code:
python import os os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/home/footageflow/helloworld2003-754c20cfa98d.json"
-
Attempted CLI Authentication:
- On my PythonAnywhere VM, I downloaded and installed the
gcloud
CLI. - I ran
gcloud auth application-default login
and authenticated successfully.
Despite all this, the error persists when I try to run my code on PythonAnywhere.
Questions:
- Is there something I'm missing with the PythonAnywhere environment or how Google Cloud ADC works?
- Are there specific permissions I need to set for the service account in Google Cloud?
- Could the issue be related to how PythonAnywhere handles environment variables or service accounts?
Additional Information:
- My Django project works perfectly locally after authenticating with
gcloud
. - I'm using PythonAnywhere to deploy my Django app.
Any help or guidance would be greatly appreciated!