// Server-to-server call to a CodeB tenant using an API key. // European Digital Identity Wallet claims are out-of-band; API keys are // for background jobs. // [m2m-cookbook 2026-07-23] // // Mint the key at https:///api-keys-admin.html // Keys have the form ak_XXXXXXXXXXXXXXXX and MUST travel over TLS. package main import ( "fmt" "io" "net/http" "os" "time" ) const Tenant = "https://" func main() { apiKey := os.Getenv("CODEB_API_KEY") if apiKey == "" { fmt.Fprintln(os.Stderr, "set CODEB_API_KEY=ak_...") os.Exit(1) } client := &http.Client{Timeout: 15 * time.Second} req, _ := http.NewRequest("GET", Tenant+"/api.ashx?action=users.list", nil) req.Header.Set("Authorization", "Bearer "+apiKey) resp, err := client.Do(req) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }