I modified the code so _get_environment() gets called only once: the very first time the GoogleCredentials.get_default() is called.