60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
/*
 | 
						|
 * Copyright 2025 coze-dev Authors
 | 
						|
 *
 | 
						|
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
						|
 * you may not use this file except in compliance with the License.
 | 
						|
 * You may obtain a copy of the License at
 | 
						|
 *
 | 
						|
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
 *
 | 
						|
 * Unless required by applicable law or agreed to in writing, software
 | 
						|
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
 * See the License for the specific language governing permissions and
 | 
						|
 * limitations under the License.
 | 
						|
 */
 | 
						|
 | 
						|
// Code generated by hertz generator.
 | 
						|
 | 
						|
package coze
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
 | 
						|
	"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"
 | 
						|
)
 | 
						|
 | 
						|
// OauthAuthorizationCode .
 | 
						|
// @router /api/oauth/authorization_code [GET]
 | 
						|
func OauthAuthorizationCode(ctx context.Context, c *app.RequestContext) {
 | 
						|
	var err error
 | 
						|
	var req bot_open_api.OauthAuthorizationCodeReq
 | 
						|
	err = c.BindAndValidate(&req)
 | 
						|
	if err != nil {
 | 
						|
		invalidParamRequestResponse(c, err.Error())
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	if req.Code == "" {
 | 
						|
		invalidParamRequestResponse(c, "code is required")
 | 
						|
		return
 | 
						|
	}
 | 
						|
	if req.State == "" {
 | 
						|
		invalidParamRequestResponse(c, "state is required")
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	resp, err := plugin.PluginApplicationSVC.OauthAuthorizationCode(ctx, &req)
 | 
						|
	if err != nil {
 | 
						|
		internalServerErrorResponse(ctx, c, err)
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	c.JSON(consts.StatusOK, resp)
 | 
						|
}
 |