8000 chore: Add base credential exchanger (Experimental) · d33bs/adk-python@a6b1baa · GitHub
[go: up one dir, main page]

Skip to content

Commit a6b1baa

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: Add base credential exchanger (Experimental)
PiperOrigin-RevId: 772227201
1 parent e384fa4 commit a6b1baa

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Credential exchanger module."""
16+
17+
from .base_credential_exchanger import BaseCredentialExchanger
18+
from .credential_exchanger_registry import CredentialExchangerRegistry
19+
from .service_account_credential_exchanger import ServiceAccountCredentialExchanger
20+
21+
__all__ = [
22+
"BaseCredentialExchanger",
23+
"CredentialExchangerRegistry",
24+
"ServiceAccountCredentialExchanger",
25+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Base credential exchanger interface."""
16+
17+
from __future__ import annotations
18+
19+
import abc
20+
from typing import Optional
21+
22+
from ...utils.feature_decorator import experimental
23+
from ..auth_credential import AuthCredential
24+
from ..auth_schemes import AuthScheme
25+
26+
27+
@experimental
28+
class BaseCredentialExchanger(abc.ABC):
29+
"""Base interface for credential exchangers."""
30+
31+
@abc.abstractmethod
32+
async def exchange(
33+
self,
34+
auth_credential: AuthCredential,
35+
auth_scheme: Optional[AuthScheme] = None,
36+
) -> AuthCredential:
37+
"""Exchange credential if needed.
38+
39+
Args:
40+
auth_credential: The credential to exchange.
41+
auth_scheme: The authentication scheme (optional, some exchangers don't need it).
42+
43+
Returns:
44+
The exchanged credential.
45+
46+
Raises:
47+
ValueError: If credential exchange fails.
48+
"""
49+
pass

0 commit comments

Comments
 (0)
0