mirror of https://github.com/langgenius/dify.git
fix(trigger): update error handling and credential expiration field
This commit is contained in:
parent
f5c1646f79
commit
24619e74f6
|
|
@ -8,6 +8,7 @@ from werkzeug.exceptions import BadRequest, Forbidden
|
|||
from configs import dify_config
|
||||
from controllers.console import api
|
||||
from controllers.console.wraps import account_initialization_required, setup_required
|
||||
from controllers.web.error import NotFoundError
|
||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||
from core.plugin.entities.plugin_daemon import CredentialType
|
||||
from core.plugin.impl.oauth import OAuthHandler
|
||||
|
|
@ -318,7 +319,7 @@ class TriggerOAuthAuthorizeApi(Resource):
|
|||
)
|
||||
|
||||
if oauth_client_params is None:
|
||||
raise Forbidden("No OAuth client configuration found for this trigger provider")
|
||||
raise NotFoundError("No OAuth client configuration found for this trigger provider")
|
||||
|
||||
# Create subscription builder
|
||||
subscription_builder = TriggerSubscriptionBuilderService.create_trigger_subscription_builder(
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ class TriggerProviderService:
|
|||
|
||||
# Update credentials
|
||||
subscription.credentials = dict(encrypter.encrypt(dict(refreshed_credentials.credentials)))
|
||||
subscription.expires_at = refreshed_credentials.expires_at
|
||||
subscription.credential_expires_at = refreshed_credentials.expires_at
|
||||
session.commit()
|
||||
|
||||
# Clear cache
|
||||
|
|
@ -448,7 +448,9 @@ class TriggerProviderService:
|
|||
session.add(custom_client)
|
||||
|
||||
# Update client params if provided
|
||||
if client_params is not None:
|
||||
if client_params is None:
|
||||
custom_client.encrypted_oauth_params = json.dumps({})
|
||||
else:
|
||||
encrypter, cache = create_provider_encrypter(
|
||||
tenant_id=tenant_id,
|
||||
config=[x.to_basic_provider_config() for x in provider_controller.get_oauth_client_schema()],
|
||||
|
|
|
|||
Loading…
Reference in New Issue