Skip to main content

Authentication

Authenticate with an API key โ€” the simplest and most reliable flow for servers, CI, and cron jobs. Mint an lh_โ€ฆ key in the portal and pass it when you construct the client.

All snippets use these imports:

import (
sdkclient "github.com/lighthouse-web3/baas-go-sdk/client"
sdktypes "github.com/lighthouse-web3/baas-go-sdk/types"
)
Use an API key for automation

For servers, CI, and cron jobs, mint an API key in the portal and use the API key flow below. It is the most reliable path.

This is the simplest and most common flow for backup jobs. When you pass an API key, the client is already authenticated โ€” you do not call Authenticate().

import (
"log"
"os"

sdkclient "github.com/lighthouse-web3/baas-go-sdk/client"
)

func newClient() *sdkclient.BackupClient {
c, err := sdkclient.NewBackupClient(sdkclient.BackupClientOptions{
APIURL: "https://baas-api.lighthouse.storage", // API host
APIKey: os.Getenv("LH_API_KEY"), // lh_โ€ฆ from the portal
WorkspaceID: os.Getenv("LH_WORKSPACE_ID"), // workspace UUID
})
if err != nil {
log.Fatalf("client init: %v", err)
}
return c
}

Switching workspaces: call client.setWorkspaceId(id) (Go: c.SetWorkspaceID(id)) to change the default, or pass workspaceId inside the backup / restore options to override for a single call.

See API Keys for how to create, scope, and rotate keys.