Developing a DLP client and Setting GOOGLE_APPLICATION_CREDENTIALS
using win shell.
API is failing with following signature:
google.auth.exceptions.DefaultCredentialsError: File "XXXXX.json" was not found.
When set in code using
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "XXXXX.json"
it works fine.
OS used windows 10.
Can any one explain the reason?
Updates
- I did set environment variable from pycharm terminal.
- I am running the code from pycharm terminal:
python my_code.py
- When i print(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]) i get the value i did set.
Issue Found:
Environmental variable was set using quotes. It should be without quotes.
set GOOGLE_APPLICATION_CREDENTIALS="path\to\secret\key"
Confusing debug message
google.auth.exceptions.DefaultCredentialsError: File "path\to\secret\key" was not found.
Resolution:
set GOOGLE_APPLICATION_CREDENTIALS=path\to\secret\key