Help us shape the future of Go! Take the 2026 Go Developer Survey

deviceflow

package
v0.1.310 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package deviceflow implements the OAuth 2.0 Device Authorization Grant (RFC 8628) for obtaining OIDC identity tokens in headless or constrained-input environments.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(tg *TokenGetter)

func WithMessagePrinter

func WithMessagePrinter(fn func(string)) Option

func WithSleeper

func WithSleeper(fn func(time.Duration)) Option

type TokenGetter

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

TokenGetter fetches an OIDC Identity token using the Device Code Grant flow as specified in RFC8628

func NewTokenGetter

func NewTokenGetter(issuer string, opts ...Option) *TokenGetter

NewTokenGetter creates a new TokenGetter that retrieves an OIDC Identity Token using a Device Code Grant

Example

ExampleNewTokenGetter demonstrates creating a TokenGetter for a given issuer.

package main

import (
	"fmt"

	"chainguard.dev/sdk/auth/deviceflow"
)

func main() {
	tg := deviceflow.NewTokenGetter("https://issuer.enforce.dev")
	fmt.Println(tg != nil)
}
Output:
true

func (*TokenGetter) CodeURL

func (d *TokenGetter) CodeURL() (string, error)

CodeURL fetches the device authorization endpoint URL from the provider's well-known configuration endpoint

func (*TokenGetter) GetIDToken

func (d *TokenGetter) GetIDToken(p *oidc.Provider, cfg oauth2.Config) (*oauthflow.OIDCIDToken, error)

GetIDToken gets an OIDC ID Token from the specified provider using the device code grant flow

Jump to

Keyboard shortcuts

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