Browse docs

Go SDK

Zero external deps — stdlib only. Verify session JWTs against the instance JWKS and administer users/orgs with the typed admin client.

Install

go get github.com/kolaylogin/kolaylogin-go

Verify a session

package main

import (
  "context"
  "net/http"
  kolay "github.com/kolaylogin/kolaylogin-go"
)

func handler(w http.ResponseWriter, r *http.Request) {
  cookie, err := r.Cookie("__session")
  if err != nil { http.Error(w, "unauthorized", 401); return }
  claims, err := kolay.VerifySessionJWT(context.Background(), cookie.Value, kolay.VerifyOptions{
    BaseURL: "https://api.kolaylogin.com",
    Issuer:  "https://example.com",
  })
  if err != nil { http.Error(w, "unauthorized", 401); return }
  _ = claims
}

Admin client

c, _ := kolay.NewClient("https://api.kolaylogin.com", os.Getenv("KL_SECRET_KEY"))

users, _ := c.Users.List(ctx, 20, 0, "")
org, _   := c.Orgs.Create(ctx, "Acme", "acme", "")
_ = c.Invites.Create(ctx, "new@example.com", orgID, "member")

Module path is github.com/kolaylogin/kolaylogin-go.