Skip to content

google.auth.exceptions.DefaultCredentialsError #2

Open

Description

@dervinism

Hi,

I am getting this error while attempting to launch the SpikeAgent: streamlit run src/unified_app.py

The web browser gives the following traceback:

File "/mnt/c/Users/m329786/Python_packages/SpikeAgent/src/unified_app.py", line 8, in <module>
    from graph_gemini import invoke_our_graph as invoke_gemini_graph
File "/mnt/c/Users/m329786/Python_packages/SpikeAgent/src/graph_gemini.py", line 333, in <module>
    gemini_2_0_flash = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", temperature=0).bind_tools(tools)
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 1108, in __init__
    super().__init__(**kwargs)
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/langchain_core/load/serializable.py", line 130, in __init__
    super().__init__(*args, **kwargs)
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 1169, in validate_environment
    self.client = genaix.build_generative_service(
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/langchain_google_genai/_genai_extension.py", line 276, in build_generative_service
    return v1betaGenerativeServiceClient(**config)
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 697, in __init__
    self._transport = transport_init(
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py", line 234, in __init__
    super().__init__(
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/transports/base.py", line 100, in __init__
    credentials, _ = google.auth.default(
File "/home/m329786/anaconda3/envs/spike_agent/lib/python3.10/site-packages/google/auth/_default.py", line 685, in default
    raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)

Activity

  1. arnaumarin commented on Jun 7, 2025

    @arnaumarin
    Collaborator

    Hi @dervinism,

    Thanks for reporting this and providing the detailed traceback! Seems like your DefaultCredentialsError means the Gemini API key is missing.

    Option 1: Add your Gemini Key

    This is the fastest fix if you want to use Gemini.

    1. Get your API key from Google AI Studio.
    2. Set the environment variable in your terminal:
      export GOOGLE_API_KEY="YOUR_API_KEY_HERE"
    3. Run the app again:
      streamlit run src/unified_app.py

    Option 2: Switch to a Different LLM (like OpenAI)

    Use this if you don't have a Gemini key.

    1. Set your other provider's API key:
      export OPENAI_API_KEY="your-sk-..."
    2. Important: You must also edit src/unified_app.py. Change the import from graph_gemini to the provider you want to use (e.g., graph_openai).

    Let us know if this resolves your issue or if you have any other questions. We can try go step by step to make sure you can run it!

  2. dervinism commented on Jun 15, 2025

    @dervinism
    Author

    Thanks for a quick reply. I have set the API keys in the environment file SpikeAgent.env but my guess is that it is not being detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions