fix(plugin): authorization code redirect to static url (#191)

This commit is contained in:
mrh997
2025-08-07 12:24:18 +08:00
committed by GitHub
parent efbc82e8b3
commit e2b1f6e381
12 changed files with 79 additions and 63 deletions

View File

@@ -20,12 +20,14 @@ package coze
import (
"context"
"fmt"
"github.com/coze-dev/coze-studio/backend/application/plugin"
"github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts"
"github.com/coze-dev/coze-studio/backend/application/plugin"
bot_open_api "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/bot_open_api"
)
@@ -41,7 +43,7 @@ func OauthAuthorizationCode(ctx context.Context, c *app.RequestContext) {
}
if req.Code == "" {
invalidParamRequestResponse(c, "code is required")
invalidParamRequestResponse(c, "authorization failed, code is required")
return
}
if req.State == "" {
@@ -49,11 +51,15 @@ func OauthAuthorizationCode(ctx context.Context, c *app.RequestContext) {
return
}
resp, err := plugin.PluginApplicationSVC.OauthAuthorizationCode(ctx, &req)
_, err = plugin.PluginApplicationSVC.OauthAuthorizationCode(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
redirectURL := fmt.Sprintf("%s/information/auth/success", conf.GetServerHost())
c.Redirect(consts.StatusFound, []byte(redirectURL))
c.Abort()
return
}