Added support for static token mode #348
Open
+97
−30
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