authorizationcode

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package authorizationcode implements the OAuth 2.0 Authorization Code Grant with the PKCE extension.

See https://tools.ietf.org/html/rfc7636

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Config is the OAuth2 configuration to use for this authorization flow
	oauth2.Config

	// EndpointParams specifies additional parameters for requests to the authorization endpoint.
	EndpointParams url.Values
	// contains filtered or unexported fields
}

Config implements an authorization code flow with proof key for code exchange.

func NewAuthorizationCodeFlowWithPKCE

func NewAuthorizationCodeFlowWithPKCE() (*Config, error)

NewAuthorizationCodeFlowWithPKCE creates a new authorization flow using the supplied OAuth2 configuration.

func (*Config) AuthCodeURLWithPKCE

func (c *Config) AuthCodeURLWithPKCE() string

AuthCodeURLWithPKCE returns the browser URL for the user to start the authorization flow.

func (*Config) Callback

func (c *Config) Callback(handler Handler, response ResponseFunc) http.Handler

Callback implements an HTTP handler for the target of the OAuth2 redirect URL.

func (*Config) CallbackAddr

func (c *Config) CallbackAddr() (string, error)

CallbackAddr returns the address of the callback server (i.e. the host of the OAuth redirect URL)

func (*Config) ExchangeWithPKCE

func (c *Config) ExchangeWithPKCE(ctx context.Context, code string) (*oauth2.Token, error)

ExchangeWithPKCE returns the access token for the authorization flow

type Handler

type Handler func(token *oauth2.Token) error

Handler is an asynchronous callback for receiving the token after a successful exchange.

type ResponseFunc

type ResponseFunc func(w http.ResponseWriter, r *http.Request, code int, err error)

ResponseFunc is used to handle response generation from the HTTP callback server.

Jump to

Keyboard shortcuts

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