I'm testing Google Cloud Pub/Sub on my Django project using VSCode on my Mac, and I'm having some problems setting GCP environment variables during debugging tests, specifically the GOOGLE_APPLICATION_CREDENTIALS environment variable.
I am able to set the GOOGLE_APPLICATION_CREDENTIALS for running server and/or tests locally with export GOOGLE_APPLICATION_CREDENTIALS="path/to/json_credential_file.json" in a shell, but as the VSCode debugger runs in a separate shell the env variable is not set when debugging tests. I tried adding the same value to the env key in launch.json:
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "path/to/json_credential_file.json"
}
But it still complains about GOOGLE_APPLICATION_CREDENTIALS not being set:
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
Any ideas?