mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac
This commit is contained in:
parent
a80d5240f6
commit
ac08529380
1 changed files with 30 additions and 29 deletions
|
|
@ -207,38 +207,39 @@ async def verify_tool_servers_config(
|
||||||
if form_data.type == "mcp":
|
if form_data.type == "mcp":
|
||||||
if form_data.auth_type == "oauth_2.1":
|
if form_data.auth_type == "oauth_2.1":
|
||||||
discovery_urls = get_discovery_urls(form_data.url)
|
discovery_urls = get_discovery_urls(form_data.url)
|
||||||
async with aiohttp.ClientSession() as session:
|
for discovery_url in discovery_urls:
|
||||||
async with session.get(
|
log.debug(
|
||||||
discovery_urls[0]
|
f"Trying to fetch OAuth 2.1 discovery document from {discovery_url}"
|
||||||
) as oauth_server_metadata_response:
|
)
|
||||||
if oauth_server_metadata_response.status != 200:
|
async with aiohttp.ClientSession() as session:
|
||||||
raise HTTPException(
|
async with session.get(
|
||||||
status_code=400,
|
discovery_urls[0]
|
||||||
detail=f"Failed to fetch OAuth 2.1 discovery document from {discovery_urls[0]}",
|
) as oauth_server_metadata_response:
|
||||||
)
|
if oauth_server_metadata_response.status == 200:
|
||||||
|
try:
|
||||||
try:
|
oauth_server_metadata = (
|
||||||
oauth_server_metadata = OAuthMetadata.model_validate(
|
OAuthMetadata.model_validate(
|
||||||
await oauth_server_metadata_response.json()
|
await oauth_server_metadata_response.json()
|
||||||
)
|
)
|
||||||
return {
|
)
|
||||||
"status": True,
|
return {
|
||||||
"oauth_server_metadata": oauth_server_metadata.model_dump(
|
"status": True,
|
||||||
mode="json"
|
"oauth_server_metadata": oauth_server_metadata.model_dump(
|
||||||
),
|
mode="json"
|
||||||
}
|
),
|
||||||
except Exception as e:
|
}
|
||||||
log.info(
|
except Exception as e:
|
||||||
f"Failed to parse OAuth 2.1 discovery document: {e}"
|
log.info(
|
||||||
)
|
f"Failed to parse OAuth 2.1 discovery document: {e}"
|
||||||
raise HTTPException(
|
)
|
||||||
status_code=400,
|
raise HTTPException(
|
||||||
detail=f"Failed to parse OAuth 2.1 discovery document from {discovery_urls[0]}",
|
status_code=400,
|
||||||
)
|
detail=f"Failed to parse OAuth 2.1 discovery document from {discovery_urls[0]}",
|
||||||
|
)
|
||||||
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail=f"Failed to fetch OAuth 2.1 discovery document from {discovery_urls[0]}",
|
detail=f"Failed to fetch OAuth 2.1 discovery document from {discovery_urls}",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue