Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release-update-adk-web.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release: Update ADk Web
name: 'Release: Update ADk Web'

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
TARGET_DIR="src/google/adk/cli/browser"
REPO="${{ github.event.inputs.adk_web_repo }}"
TAG="${{ github.event.inputs.adk_web_tag }}"
TAG="${{ github.event.inputs.adk_web_tag }}"
# Clean target directory
rm -rf "$TARGET_DIR"/*
mkdir -p "$TARGET_DIR"
Expand Down
56 changes: 49 additions & 7 deletions src/google/adk/auth/auth_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ async def exchange_auth_token(
return exchange_result.credential

async def parse_and_store_auth_response(self, state: State) -> None:
credential_key = self.auth_config.credential_key
if not credential_key:
raise ValueError("credential_key is empty.")

credential_key = "temp:" + self.auth_config.credential_key
temp_credential_key = "temp:" + credential_key

state[credential_key] = self.auth_config.exchanged_auth_credential
state[temp_credential_key] = self.auth_config.exchanged_auth_credential
if not isinstance(
self.auth_config.auth_scheme, SecurityBase
) or self.auth_config.auth_scheme.type_ not in (
Expand All @@ -67,15 +70,54 @@ async def parse_and_store_auth_response(self, state: State) -> None:
):
return

state[credential_key] = await self.exchange_auth_token()
state[temp_credential_key] = await self.exchange_auth_token()

def _validate(self) -> None:
if not self.auth_scheme:
if not self.auth_config.auth_scheme:
raise ValueError("auth_scheme is empty.")

def get_auth_response(self, state: State) -> AuthCredential:
credential_key = "temp:" + self.auth_config.credential_key
return state.get(credential_key, None)
def get_auth_response(self, state: State) -> AuthCredential | None:
# 1. Try reading the temp credential key (standard ADK flow)
credential_key = self.auth_config.credential_key
if not credential_key:
return None

temp_credential_key = "temp:" + credential_key
val = state.get(temp_credential_key, None)
if val is not None:
if isinstance(val, AuthCredential):
return val
if isinstance(val, str) and val:
return self._build_oauth2_credential(val)

# 2. Try reading the credential key without the 'temp:' prefix
val = state.get(credential_key, None)
if val is not None:
if isinstance(val, AuthCredential):
return val
if isinstance(val, str) and val:
return self._build_oauth2_credential(val)

# 3. Fallback: scan the state for any active Google OAuth access token (ya29.*)
try:
state_dict = state.to_dict() if hasattr(state, "to_dict") else state
if isinstance(state_dict, dict):
for k, v in state_dict.items():
if isinstance(v, str) and v.startswith("ya29."):
return self._build_oauth2_credential(v)
except Exception: # pylint: disable=broad-except
pass

return None

def _build_oauth2_credential(self, token: str) -> AuthCredential:
from .auth_credential import AuthCredentialTypes
from .auth_credential import OAuth2Auth

return AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(access_token=token),
)

def generate_auth_request(self) -> AuthConfig:
if not isinstance(
Expand Down
4 changes: 2 additions & 2 deletions src/google/adk/cli/browser/chunk-3YZ77ADE.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/adk/cli/browser/chunk-B2DSW4QB.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import{g as e}from"./chunk-JRNAXTJ7.js";var l=e(()=>`
overflow: visible;
vertical-align: -0.125em;
}

.node .label-icon path {
fill: currentColor;
stroke: revert;
Expand Down
2 changes: 1 addition & 1 deletion src/google/adk/cli/browser/chunk-BDIW4D5I.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading