feat(oauth): add support for retrieving credential info and OAuth client schema

This commit is contained in:
Harry
2025-07-02 14:58:44 +08:00
parent 7951a1c4df
commit 6ef1e017df
4 changed files with 85 additions and 6 deletions

View File

@ -134,6 +134,17 @@ class BuiltinToolProviderController(ToolProviderController):
"""
return self.entity.oauth_schema.client_schema.copy() if self.entity.oauth_schema else []
def get_supported_credential_types(self) -> list[str]:
"""
returns the credential support type of the provider
"""
types = []
if self.entity.credentials_schema is not None:
types.append(ToolProviderCredentialType.API_KEY.value)
if self.entity.oauth_schema is not None:
types.append(ToolProviderCredentialType.OAUTH2.value)
return types
def get_tools(self) -> list[BuiltinTool]:
"""
returns a list of tools that the provider can provide

View File

@ -81,3 +81,8 @@ class ToolProviderCredentialApiEntity(BaseModel):
default=False, description="Whether the credential is the default credential for the provider in the workspace"
)
credentials: dict = Field(description="The credentials of the provider")
class ToolProviderCredentialInfoApiEntity(BaseModel):
supported_credential_types: list[str] = Field(description="The supported credential types of the provider")
credentials: list[ToolProviderCredentialApiEntity] = Field(description="The credentials of the provider")