widgets

package
v6.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 9 Imported by: 0

README

widgets

Go Report Card

A Go package to make requests to the WorkOS Widgets API.

Install

go get -u github.com/workos/workos-go/v6/pkg/widgets

How it works

See the Widgets integration guide.

Documentation

Overview

Package `widgets` provides a client wrapping the WorkOS Widgets API.

Index

Constants

View Source
const ResponseLimit = 10

ResponseLimit is the default number of records to limit a response to.

Variables

View Source
var (
	DefaultClient = &Client{
		Endpoint: "https://api.workos.com",
	}
)

DefaultClient is the client used by SetAPIKey and Widgets functions.

Functions

func GetToken

func GetToken(
	ctx context.Context,
	opts GetTokenOpts,
) (string, error)

GetToken generates an ephemeral widget token based on the provided options.

func SetAPIKey

func SetAPIKey(apiKey string)

SetAPIKey sets the WorkOS API key for Widgets API requests.

Types

type Client

type Client struct {
	// The WorkOS API Key. It can be found in https://dashboard.workos.com/api-keys.
	APIKey string

	// The http.Client that is used to manage Widgets API calls to WorkOS.
	// Defaults to http.Client.
	HTTPClient *http.Client

	// The endpoint to WorkOS API. Defaults to https://api.workos.com.
	Endpoint string

	// The function used to encode in JSON. Defaults to json.Marshal.
	JSONEncode func(v interface{}) ([]byte, error)
	// contains filtered or unexported fields
}

Client represents a client that performs Widgets requests to the WorkOS API.

func (*Client) GetToken

func (c *Client) GetToken(
	ctx context.Context,
	opts GetTokenOpts,
) (string, error)

GetToken generates a widget token based on the provided options.

type GetTokenOpts

type GetTokenOpts struct {
	// Organization identifier to scope the widget token
	OrganizationId string `json:"organization_id"`

	// AuthKit user identifier to scope the widget token
	UserId string `json:"user_id"`

	// WidgetScopes to scope the widget token
	Scopes []WidgetScope `json:"scopes"`
}

GetTokenOpts contains the options to get a widget token.

type GetTokenResponse

type GetTokenResponse struct {
	// Generated widget token
	Token string `json:"token"`
}

GetTokenResponse represents the generated widget token

type WidgetScope

type WidgetScope string

WidgetScope represents a widget token scope.

const (
	UsersTableManage WidgetScope = "widgets:users-table:manage"
)

Constants that enumerate the available GenerateLinkIntent types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL