Added support for static token mode#348
Open
mads-digitial-solutions wants to merge 2 commits into
Open
Conversation
Author
Removed Static Token ValidationWhyIn static token mode, the server was calling Google's userinfo endpoint at startup to validate the token and fetch the user's email. This required the Since the token is provided externally, the caller already knows the user identity. The userinfo call was unnecessary and added a scope requirement that shouldn't be needed. What Changed
The server now trusts the provided token and uses it directly for API requests. |
Owner
|
Hm, very interesting - I'm not entirely clear how this would function mechanically. Would this be using domain wide delegation and building a service object on behalf? We would need significant docs to roll out something like this. |
Repository owner
deleted a comment from
kapilthakare-cyberpunk
Feb 17, 2026
guifran001
added a commit
to guifran001/google_workspace_mcp
that referenced
this pull request
May 4, 2026
Introduces WORKSPACE_MCP_USE_HEADER_TOKEN (also --use-header-token CLI flag) that lets the server forward an incoming Authorization: Bearer <token> header directly to Google APIs, requiring no OAuth client credentials. - oauth_config: new `header_token_mode` flag; skips FastMCP OAuth provider setup; validated as mutually exclusive with OAuth 2.1 and service account modes - auth_info_middleware: in header token mode, extracts the raw bearer token and stores it in request context as `raw_access_token` - service_decorator: new `_authenticate_service_header_token` path that builds google.oauth2.credentials.Credentials(token=raw_token) directly, bypassing the credential store; user_google_email remains a required tool parameter (OAuth 2.0 style) so no tokeninfo resolution is needed - main.py: simplified config display, skips credential directory check and OAuth callback server when the mode is active - tests: 9 new tests covering config flags, mutual-exclusion guards, middleware passthrough, and the service decorator credential path; fix two existing tests that broke when WORKSPACE_MCP_USE_HEADER_TOKEN was present in the environment alongside MCP_ENABLE_OAUTH21 Closes taylorwilsdon#348 (static-token variant) while generalising to per-request passthrough so that existing client-side OAuth flows work transparently.
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static Access Token Mode
Overview
Add support for providing a Google access token via environment variable, bypassing the OAuth flow entirely. This enables use cases where an external system handles OAuth and provides tokens to this server.
Use Case
Service account replacement - an external system performs OAuth authentication and provides a valid Google access token. This server uses that token for all Google API requests without managing the OAuth flow itself.
Behavior
Configuration
New environment variable:
GOOGLE_ACCESS_TOKENWhen
GOOGLE_ACCESS_TOKENis set:Implementation
1. OAuth Config (
/auth/oauth_config.py)Add properties to
OAuthConfig:2. Google Auth (
/auth/google_auth.py)Add module-level state:
Add validation function:
Add credential builder:
Update
get_credentials()- add check at top:Update
start_auth_flow()- add check at top:3. Main (
/main.py)Startup validation - validate token before server starts:
Skip credentials directory check - not needed in static token mode:
Skip OAuth callback server - no OAuth flow in static token mode:
Simplified config display - only show relevant variables:
Files Changed
/auth/oauth_config.pystatic_access_tokenandis_static_token_modeproperties, mutual exclusivity validation/auth/google_auth.pyvalidate_static_token(),_build_static_credentials(), module-level_static_token_user_email, updateget_credentials()andstart_auth_flow()/main.pyError Scenarios