Skip to content

.Net: Google Gemini - Move API key from the URL to x-goog-api-key HTTP header #12717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rogerbarreto
Copy link
Member

Motivation and Context

The implementation successfully addresses the security concern raised in GitHub issue #12666 by moving the Google API key from the URL query parameter to the secure x-goog-api-key HTTP header, preventing sensitive information from being logged or traced.

  • Modified ClientBase class to support API key in headers
  • Updated all Google AI clients (Chat, Streaming, Token Counter, Embeddings) to use header-based authentication
  • Removed API key from URLs to prevent exposure in logs and OTEL traces
  • Comprehensive Testing:

@rogerbarreto rogerbarreto self-assigned this Jul 15, 2025
@rogerbarreto rogerbarreto requested a review from a team as a code owner July 15, 2025 10:40
@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Jul 15, 2025
@github-actions github-actions bot changed the title Adding ApiKey to header instead of querystring .Net: Adding ApiKey to header instead of querystring Jul 15, 2025
@rogerbarreto rogerbarreto changed the title .Net: Adding ApiKey to header instead of querystring .Net: Google Gemini - Move API key from the URL to x-goog-api-key HTTP header Jul 15, 2025
@rogerbarreto rogerbarreto moved this to Sprint: In Review in Semantic Kernel Jul 15, 2025
@rogerbarreto rogerbarreto added this pull request to the merge queue Jul 16, 2025
Merged via the queue into microsoft:main with commit e44bfb1 Jul 16, 2025
23 checks passed
@rogerbarreto rogerbarreto deleted the issues/12666-google-gemini-apikey-header branch July 16, 2025 10:30
@github-project-automation github-project-automation bot moved this from Sprint: In Review to Sprint: Done in Semantic Kernel Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

.Net: Bug: GoogleAI Gemini Api key credential should be passed using headers value?
4 participants