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 ¶
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.
Types ¶
This section is empty.