generate

package module
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

HEY Go SDK

go get github.com/basecamp/hey-sdk/go@latest

Requires Go 1.26+. See the repository guide for authentication, linked accounts, services, errors, pagination and resilience. Generated schema types preserve the modeled wire representation, including nullable recording categories.

A 401 is answered by one credential refresh per set of credentials, shared by every request signed with them and by every client derived from the same root; a refresh that fails is shared too, and a request signed after it asks again. The refresh runs on a context that outlives the request that drew the 401, bound by the client's request timeout; a request whose own context ends while it waits returns its context's error and leaves the refresh running. When the SDK's bearer strategy signed the request, the provider is asked what it would sign with first: a token it has already renewed is resent without a refresh, and a provider that cannot hand over a token at all is the refresh failing. A non-idempotent write HEY answered with a redirect may already be made (a 302 or 303 can answer a write that went through): a 401 on its hop refreshes, and is the caller's rather than a reason to risk making the write twice. An idempotent operation is resent as any other.

cfg := hey.DefaultConfig()
client := hey.NewClient(cfg, &hey.StaticTokenProvider{Token: os.Getenv("HEY_TOKEN")})
boxes, err := client.Boxes().List(context.Background())

HEY's token endpoint is client.OAuth(): CreateToken trades an authorization code or a refresh token for tokens, and RevokeToken revokes one. Both go out unsigned — no Authorization header, whatever the client holds — and a 401 is their answer, never a reason to refresh; neither follows a redirect, so a 3xx is an error carrying its status and the body's secrets go nowhere else. A client account-scoped with ForAccount sends them unscoped. NewClient refuses a client given neither a token provider nor a strategy; one meant to hold no credentials says so with NoCredentials, and refuses every other operation with auth_required before sending it:

client := hey.NewClient(cfg, nil, hey.WithAuthStrategy(hey.NoCredentials{}))
token, err := client.OAuth().CreateToken(ctx, generated.CreateTokenRequestContent{
	GrantType: "authorization_code", ClientId: clientID, InstallId: installID,
	Code: code, RedirectUri: redirectURI, CodeVerifier: verifier,
})

The token endpoint refuses with RFC 6749's {"error", "error_description"}: the description is the error's Message, and the code is its OAuthCode, which tells a dead refresh token (invalid_grant) from a misconfigured client (invalid_client) on a 401. The generated client used on its own leaves the credentials to the editors it is given, but it does take a 401 on these operations as the answer and, handed an *http.Client, follows no redirect for them.

The oauth package's Exchanger remains the client for an authorization server the caller discovered.

The existing service tests are hermetic usage examples. From the repository root, run make go-check conformance-go; the complete shipped SDK gate is make check (requires TypeScript dependencies installed with make ts-install).

Documentation

Overview

Package generate provides code generation directives for the HEY SDK.

Run `go generate ./...` from the go directory to regenerate the client code.

The generator reads openapi.json with each operation's idempotency decided from the x-hey-idempotent override, behavior-model.json and the verb, written onto the operation as x-go-idempotent by scripts/merge-behavior-model. The merged document is a build intermediate and is not checked in.

Directories

Path Synopsis
pkg
generated
Package generated provides primitives to interact with the HEY HTTP API.
Package generated provides primitives to interact with the HEY HTTP API.
hey
Package hey provides a Go SDK for the HEY API.
Package hey provides a Go SDK for the HEY API.
hey/oauth
Package oauth provides OAuth 2.0 discovery, token exchange, and refresh functionality.
Package oauth provides OAuth 2.0 discovery, token exchange, and refresh functionality.
types
Package types provides shared types used across the HEY SDK.
Package types provides shared types used across the HEY SDK.

Jump to

Keyboard shortcuts

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