oauth

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateState

func GenerateState() (string, error)

GenerateState generates a random state parameter for CSRF protection

Types

type Client

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

Client handles OAuth2 authorization flow

func NewClient

func NewClient(site string) *Client

NewClient creates a new OAuth client

func (*Client) BuildAuthorizationURL

func (c *Client) BuildAuthorizationURL(
	clientID string,
	redirectURI string,
	state string,
	challenge *PKCEChallenge,
	scopes []string,
) string

BuildAuthorizationURL builds the OAuth2 authorization URL with PKCE

func (*Client) GetAuthConfig

func (c *Client) GetAuthConfig(scopes []string) *types.AuthConfig

GetAuthConfig returns the authentication configuration

func (*Client) ParseCallbackError

func (c *Client) ParseCallbackError(errorCode, errorDescription string) error

ParseCallbackError parses OAuth error from callback parameters

func (*Client) ValidateCallback

func (c *Client) ValidateCallback(code, state, expectedState string) error

ValidateCallback validates the OAuth callback parameters

type PKCEChallenge

type PKCEChallenge struct {
	Verifier  string
	Challenge string
	Method    string
}

PKCEChallenge represents a PKCE code challenge

func GeneratePKCEChallenge

func GeneratePKCEChallenge() (*PKCEChallenge, error)

GeneratePKCEChallenge generates a PKCE code verifier and challenge Uses S256 method as specified in RFC 7636

Jump to

Keyboard shortcuts

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