wwwauth

package
v1.22.9 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 2 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 wwwauth builds RFC 6750 (OAuth 2.0 Bearer Token) WWW-Authenticate response headers. It is a small, dependency-free package so that both the api and auth packages can share a single RFC 6750 implementation without creating an import cycle (auth must not import api).

Index

Constants

View Source
const (
	// ErrInvalidRequest indicates the request is malformed or missing parameters.
	ErrInvalidRequest = "invalid_request"
	// ErrInvalidToken indicates the token is expired, revoked, or malformed.
	ErrInvalidToken = "invalid_token"
	// ErrInsufficientScope indicates the request requires higher privileges.
	ErrInsufficientScope = "insufficient_scope"
)

RFC 6750 section 3.1 error codes.

View Source
const Realm = "tmi"

Realm identifies the protection space for Bearer token authentication. This is a static value for TMI's API - all protected endpoints share the same realm.

Variables

This section is empty.

Functions

func BuildHeader

func BuildHeader(errType, description string) string

BuildHeader builds the value for a RFC 6750 compliant WWW-Authenticate header. Per RFC 6750 section 3, the value always includes the realm and optionally an error and error_description. This is the single source of truth for the header format so a compliance change lands in one place.

Parameters:

  • errType: Error code (invalid_request, invalid_token, insufficient_scope) or empty for a basic challenge
  • description: Human-readable error description (optional, ignored if errType is empty)

Types

This section is empty.

Jump to

Keyboard shortcuts

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