Overview
The Secrets API through theSecretsClient allows a Room to securely handle OAuth tokens and user-scoped secrets. Use it to:
- Request an OAuth access token for a participant
- Fetch a saved “offline” token for a participant if one already exists
- List saved secrets in a room
- Delete a secret
CLI Note: Room-scoped secrets and OAuth actions are undermeshagent oauth2. For project wide or image-pull secrets, usemeshagent secret.
API Methods
list_user_secrets
- Description: List secrets saved to the current room.
- Parameters: None.
- Returns:
list[SecretInfo](id,type,name,delegated_to| None)
delete_user_secret
- Description: Delete a stored secret by ID.
- Parameters:
id: str— secret IDdelegated_to: str | None- who the secret is delegated to
- Returns:
None
request_oauth_token
- Description: Run an OAuth flow and return an access token after the target participant grants consent. If a valid credential already exists, the server may refresh and return it without prompting the user to sign-in.
- Parameters:
client_id: strauthorization_endpoint: strtoken_endpoint: strclient_secret: str | None (use only if unable to use PKCE)scopes: list[str] | Nonetimeout: int (seconds; default 300)from_participant_id: str — participant who must approveredirect_uri: strno_pkce: bool (default False; set True to disable PKCE)
- Returns:
str(access token) - Notes: Requests are checked against the SecretsGrant to ensure the appropriate permissions are applied.
get_offline_oauth_token
- Description: Retrieve a previously saved token for a participant—no prompt shown. Returns None if there isn’t one. This is useful for email based agents that cannot display an interactive UI to the user.
- Parameters:
- client_id: str
- authorization_endpoint: str
- token_endpoint: str
- client_secret: str | None
- scopes: list[str] | None
- timeout: int (seconds; default 300)
- participant_name: str — whose offline token to fetch
- Returns:
str | None(access token or None)
provide_oauth_authorization
- Description: Approve an OAuth prompt by sending the authorization code for a pending request. Use this only if your app shows the user the oauth approval UI (after
request_oauth_tokenis called). For example, an agent might callrequest_oauth_tokeninside a tool, if so then the UI must callprovide_oauth_authorizationto… - Parameters:
request_id: str — ID of the pending request you’re answeringcode: str — authorization code returned by the provider after the user authenticates
- Returns:
None
reject_oauth_authorization
- Description: Deny an OAuth prompt when the user cancels or an error occurs in your approval UI.
- Parameters:
request_id: str — ID of the pending request you’re answeringerror: str — short reason (e.g., “user_cancelled”, “invalid_state”)
- Returns:
None