60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
"inou/lib"
|
|
)
|
|
|
|
func main() {
|
|
if err := lib.CryptoInit("/tank/inou/master.key"); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error loading master key: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err := lib.DBInit("/tank/inou/data/inou.db"); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error initializing DB: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
defer lib.DBClose()
|
|
|
|
// Check if Anthropic client already exists
|
|
existing, _ := lib.OAuthClientGet("anthropic")
|
|
if existing != nil {
|
|
fmt.Println("Anthropic OAuth client already exists:")
|
|
fmt.Printf(" Client ID: %s\n", existing.ClientID)
|
|
fmt.Printf(" Name: %s\n", existing.Name)
|
|
fmt.Printf(" Created: %d\n", existing.CreatedAt)
|
|
uris, _ := json.MarshalIndent(existing.RedirectURIs, " ", " ")
|
|
fmt.Printf(" Redirect URIs:\n %s\n", uris)
|
|
os.Exit(0)
|
|
}
|
|
|
|
// Create Anthropic client with required callback URLs
|
|
redirectURIs := []string{
|
|
"https://claude.ai/api/mcp/auth_callback",
|
|
"https://claude.com/api/mcp/auth_callback",
|
|
"http://localhost:6274/oauth/callback",
|
|
"http://localhost:6274/oauth/callback/debug",
|
|
}
|
|
|
|
client, secret, err := lib.OAuthClientCreate("Anthropic Claude", redirectURIs)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error creating client: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println("Created Anthropic OAuth client:")
|
|
fmt.Printf(" Client ID: %s\n", client.ClientID)
|
|
fmt.Printf(" Client Secret: %s\n", secret)
|
|
fmt.Println()
|
|
fmt.Println("IMPORTANT: Save the client secret securely. It cannot be retrieved later.")
|
|
fmt.Println()
|
|
fmt.Println("For Anthropic submission, provide these OAuth endpoints:")
|
|
fmt.Println(" Authorization URL: https://inou.com/oauth/authorize")
|
|
fmt.Println(" Token URL: https://inou.com/oauth/token")
|
|
fmt.Println(" UserInfo URL: https://inou.com/oauth/userinfo")
|
|
}
|