fix(trigger): enhance OAuth client response in TriggerOAuthClientManageApi

- Integrated TriggerManager to retrieve the trigger provider's OAuth client schema.
- Updated the return structure to include the redirect URI and OAuth client schema for improved API response clarity.
This commit is contained in:
Harry 2025-09-10 17:23:31 +08:00
parent d22404994a
commit bd5cf1c272
1 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,7 @@ from core.plugin.entities.plugin import TriggerProviderID
from core.plugin.entities.plugin_daemon import CredentialType
from core.plugin.impl.oauth import OAuthHandler
from core.trigger.entities.entities import SubscriptionBuilderUpdater
from core.trigger.trigger_manager import TriggerManager
from extensions.ext_database import db
from libs.login import current_user, login_required
from models.account import Account
@ -445,13 +446,15 @@ class TriggerOAuthClientManageApi(Resource):
tenant_id=user.current_tenant_id,
provider_id=provider_id,
)
return {
provider_controller = TriggerManager.get_trigger_provider(user.current_tenant_id, provider_id)
return jsonable_encoder({
"configured": bool(custom_params or system_client),
"oauth_client_schema": provider_controller.get_oauth_client_schema(),
"custom_configured": bool(custom_params),
"custom_enabled": is_custom_enabled,
"redirect_uri": f"{dify_config.CONSOLE_API_URL}/console/api/oauth/plugin/{provider}/trigger/callback",
"params": custom_params if custom_params else {},
}
})
except Exception as e:
logger.exception("Error getting OAuth client", exc_info=e)