tokenclient

package
v0.0.1-dev.10 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 8 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.

Documentation

Overview

Package tokenclient creates the OAuth client through which one personal API token is minted. Its wire members are named after RFC 7591 §2 and RFC 7591 §3.2.1; the shared bearer stands in for the initial access token. The backend fixes the other client properties, including a 30-day access token lifetime. This is not an RFC 7591 registration endpoint.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid     = errors.New("token client invalid")
	ErrUnavailable = errors.New("token client unavailable")
)

Functions

func Handler

func Handler(backend Backend, bearer string) http.Handler

Handler serves backend at POST /v1/token-clients. Every request carries the shared bearer.

Types

type Backend

type Backend interface {
	Create(context.Context, Request) (Credentials, error)
}

Backend creates a client for one personal token. Create is not idempotent: every successful call creates a new client.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls Handler from Holon's side.

func NewClient

func NewClient(endpoint, bearer string, transport *http.Client) (*Client, error)

NewClient returns a client for the adapter at endpoint, the base URL for /v1/token-clients.

func (*Client) Create

func (c *Client) Create(ctx context.Context, request Request) (Credentials, error)

Create posts a request. A refusal is ErrInvalid; any other failure is ErrUnavailable. Retrying a request can create another client even when the first response was lost.

type Credentials

type Credentials struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

Credentials identify the created client and contain its secret.

type Request

type Request struct {
	Name string `json:"client_name"`
}

Request names the client. Names may be reused and are stored as supplied.

Jump to

Keyboard shortcuts

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