← Files WorkOSARCHIVED FILE

references/framework-go.md

731 Bytes · Oct 2, 2026 · 00:06 UTC

↓ Download file

# Framework: Go

## Scope

Use this guide for Go services that issue widget tokens and support widget API integration.

## Guidance

- Use the official WorkOS Go SDK.
- Keep API key in environment configuration.
- Place token generation in existing handler/service layers.
- Reuse existing auth/session middleware to derive organization/user identifiers.

## Token Pattern

```go
import (
  "context"
  "os"

  "github.com/workos/workos-go/v4/pkg/widgets"
)

widgets.SetAPIKey(os.Getenv("WORKOS_API_KEY"))

token, err := widgets.GetToken(
  context.Background(),
  widgets.GetTokenOpts{
    OrganizationID: organizationID,
    UserID:         userID,
    Scopes:         []widgets.WidgetScope{widgets.UsersTableManage},
  },
)
```

SHA-256: f30698142ef96f2c505b1ecb4eecd6f9c90865a13bc9079f90a708189ae90553