deviceflow

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 9 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 deviceflow coordinates the OAuth 2.0 device authorization grant (RFC 8628) against a configured authorization server.

Status: CANDIDATE. Capability: identity.device-flow.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid  = errors.New("deviceflow: invalid input")
	ErrDenied   = errors.New("deviceflow: denied")
	ErrPending  = errors.New("deviceflow: authorization pending")
	ErrExpired  = errors.New("deviceflow: expired")
	ErrSlowDown = errors.New("deviceflow: slow down")
)

Functions

This section is empty.

Types

type Client

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

Client polls a device-flow authorization server.

func New

func New(cfg Config) (*Client, error)

New validates config.

func (*Client) Poll

func (c *Client) Poll(ctx context.Context, deviceCode DeviceCode) (Token, error)

Poll waits until the user authorizes or the context is cancelled.

func (*Client) Request

func (c *Client) Request(ctx context.Context) (DeviceCode, error)

Request starts the device authorization.

type Config

type Config struct {
	ClientID      string
	DeviceAuthURL string
	TokenURL      string
	Scopes        []string
	HTTPClient    *http.Client
}

Config binds device and token endpoints. URLs are configured absolutes.

type DeviceCode

type DeviceCode struct {
	DeviceCode              string
	UserCode                string
	VerificationURI         string
	VerificationURIComplete string
	ExpiresIn               int
	Interval                int
}

DeviceCode is returned by Request.

type Token

type Token struct {
	AccessToken  string
	TokenType    string
	RefreshToken string
	Scope        string
	ExpiresIn    int
}

Token is returned after the user authorizes.

Jump to

Keyboard shortcuts

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