loopback

package
v1.104.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package loopback authorizes an installed app in the user's browser: it listens on a loopback address for the redirect that carries the authorization code, and exchanges the code for a token.

It is the flow RFC 8252 describes for native apps, with PKCE (RFC 7636): the code is bound to a verifier only this process holds, so another program on the machine that catches the redirect cannot spend it.

Index

Constants

This section is empty.

Variables

View Source
var ErrDenied = errors.New("authorization denied")

ErrDenied is the user, or the authorization server, refusing the authorization.

Functions

func Authorize

func Authorize(
	ctx context.Context,
	config *oauth2Config.Config,
	openUrl func(string) error,
	options ...auth_code_option.AuthCodeOption,
) (*token.Token, error)

Authorize has the user authorize the config's client in the browser and returns the token the code is exchanged for. openUrl is given the authorization URL to send the user to: it may open a browser, print the URL, or both.

The redirect is to 127.0.0.1 on a port chosen now, which the config's own RedirectURL is replaced by; an installed app's client takes any port of a loopback address. The options are added to the authorization URL, as access_type=offline for a refresh token or login_hint for the account to sign in as.

func Challenge

func Challenge(verifier string) string

Challenge is the S256 code challenge of a PKCE verifier.

Types

This section is empty.

Jump to

Keyboard shortcuts

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