devicecode

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package devicecode implements the shared device code polling loop for OAuth flows.

Index

Constants

This section is empty.

Variables

View Source
var ErrPending = errors.New("authorization pending")

ErrPending indicates the user has not yet authorized.

View Source
var ErrSlowDown = errors.New("slow down")

ErrSlowDown indicates the poll interval should be increased.

Functions

func Run

func Run(ctx context.Context, cfg Config) (string, error)

Run executes the device code polling loop, printing instructions to stderr.

Types

type Config

type Config struct {
	// UserCode is the code the user must enter in the browser.
	UserCode string
	// VerificationURL is the URL the user must visit.
	VerificationURL string
	// Interval is the minimum seconds between poll attempts.
	Interval int
	// ExpiresIn is the total seconds before the device code expires.
	ExpiresIn int
	// Poll is called on each iteration. It must return the result token or a sentinel error.
	// Return ErrPending to continue polling, ErrSlowDown to increase interval.
	Poll func(ctx context.Context) (string, error)
}

Config describes a device code polling session.

Jump to

Keyboard shortcuts

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