inou/portal/oauth_chatgpt.go

34 lines
797 B
Go

package main
import (
"fmt"
"inou/lib"
)
// CreateChatGPTClient creates the OAuth client for ChatGPT Custom GPT Actions.
// Call this once during setup — see docs/chatgpt-actions-setup.md.
func CreateChatGPTClient() error {
_, err := lib.OAuthClientGet("chatgpt")
if err == nil {
return nil // Already exists
}
redirectURIs := []string{
"https://chat.openai.com/aip/g-*/oauth/callback",
"https://chatgpt.com/aip/g-*/oauth/callback",
}
client, secret, err := lib.OAuthClientCreate("ChatGPT Actions", redirectURIs)
if err != nil {
return err
}
fmt.Printf("Created ChatGPT OAuth client:\n")
fmt.Printf(" Client ID: %s\n", client.ClientID)
fmt.Printf(" Client Secret: %s\n", secret)
fmt.Printf(" (Save the secret - it cannot be retrieved later)\n")
return nil
}