Integration examples and authentication
Separate browser/OIDC application flows from machine administration.
Choose the right client
Use a normal standards-based OIDC client or the separately distributed starter examples for user authentication. Use the Clavex management SDK only for authorized administration. A public browser app must not contain a management API key, confidential client secret or installation key.
Published versions: Go v0.5.0, Node 2.0.0, Terraform 0.4.0. These versions are published; use the versioned registry packages. Migration and component versions.
Go: explicit scoped management credential
package main
import (
"context"
"log"
"os"
clavex "github.com/clavex-eu/clavex-sdk-go"
)
func main() {
c, err := clavex.New(os.Getenv("CLAVEX_BASE_URL"),
clavex.WithAPIKey(os.Getenv("CLAVEX_API_KEY")))
if err != nil { log.Fatal("invalid management configuration") }
_, err = c.Clients.List(context.Background(), os.Getenv("CLAVEX_ORG_ID"))
if err != nil { log.Fatal("authorized request failed") }
}
Node: server-side only
import { ClavexClient } from "@clavex/sdk";
const client = new ClavexClient(process.env.CLAVEX_BASE_URL, {
apiKey: process.env.CLAVEX_API_KEY,
});
// An independently authorized management JWT may use `token` instead.
// Never combine credentials or put API keys into a browser bundle.
Old WithCredentials / SDK email-password helpers and login() do not obtain an administrative token. They fail with a migration error; there is no cookie extraction/fallback. Interactive human console login remains supported. Privileged policy actions may require authorized human or workload proof and cannot be bypassed with an API key.
Application authorization code and PKCE
Register an exact callback, use a public client when appropriate, and send state, nonce and PKCE S256. Keep the verifier/state bound to the legitimate transaction. Discover the configured tenant issuer at /{org_slug}/.well-known/openid-configuration; use its actual endpoints.
At the real callback, validate state and use the original verifier for the code exchange. Before creating an application session validate the ID token's trusted issuer, audience, signature, nonce and time constraints. Use the supported application library/starter instead of treating a browser-supplied code or decoded JWT as proof.
# Public-client exchange. Supply only the actual registered transaction values.
curl --fail-with-body "$ISSUER/token" \
--data-urlencode grant_type=authorization_code \
--data-urlencode "client_id=$CLIENT_ID" \
--data-urlencode "code=$CODE" \
--data-urlencode "redirect_uri=$REDIRECT_URI" \
--data-urlencode "code_verifier=$PKCE_VERIFIER"
Use the client's registered authentication method for confidential clients. Do not change method to make a failing request pass. Keep tokens out of logs/history and validate server-side; never paste tokens into a public decoder.
M2M and federation
Client credentials, workload federation and SPIFFE use distinct registered/policy-authorized profiles. Their tokens do not become management authority by being called “agent” tokens. Machine identity · Federation lifecycle.
Authoritative references
Release OpenAPI documents mounted routes, bodies, authentication and errors. Automation guide covers safe resource import/revision checks. The public examples repository remains separate; pin examples to the package versions they declare.
Clavex 3.0.1 is publicly available. Release scope · Evidence and limitations · Editions and licensing