Skip to content

Helper functions to get token from HTTPBearer, Session state key or credentials service #2446

@bimission

Description

@bimission

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Is your feature request related to a problem? Please describe.
ADK works well when it controls OAUth flow. However when ADK agents gets access token from external system - there is no standardized way to get that token. Token can be passed through HTTP Bearer, Session State or Credentials Service. Having helper functions that would be used in auth_credential object to specify from where ADK should take the token would help

Describe the solution you'd like
A clear and concise description of what you want to happen.

auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
access_token=---->>>>>> HELPER <<<<<<<<<<<<< # Set the existing access token
)
)

auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
access_token=existing_access_token # Set the existing access token
)
)

Like:
auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
access_token=AuthHelper.GetHTTPBearer() # to dynamically get token from HTTP bearer at runtime
)
)

auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
access_token=AuthHelper.GetFromSessionStateKey(key_name) # to dynamically get from session state
)
)

auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(
access_token=AuthHelper.GetCredentialsService(key_name) # to dynamically get from Credentials Service
)
)

Image

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Labels

services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions