oauth

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageError   = "htmlPages/error.html"
	PageSuccess = "htmlPages/success.html"
	PageWaiting = "htmlPages/waiting.html"
	StylePage   = "htmlPages/output.css"
)

Variables

View Source
var DefaultHTTPClient = &http.Client{Timeout: 10 * time.Second}

DefaultHTTPClient is used for token exchange when no client is supplied.

Functions

func ExchangeAuthorizationCode

func ExchangeAuthorizationCode(ctx context.Context, httpClient *http.Client, env *environments.EnvironmentSet, code, codeVerifier string) (*credentials.CreLoginTokenSet, error)

ExchangeAuthorizationCode exchanges an OAuth authorization code for tokens using environment credentials (AuthBase, ClientID) and PKCE code_verifier.

func GeneratePKCE

func GeneratePKCE() (verifier, challenge string, err error)

GeneratePKCE returns an RFC 7636 S256 code verifier and code challenge.

func NewCallbackHTTPServer

func NewCallbackHTTPServer(listenAddr string, callback http.HandlerFunc) (*http.Server, net.Listener, error)

NewCallbackHTTPServer listens on listenAddr and serves callback on /callback.

func OpenBrowser

func OpenBrowser(urlStr string, goos string) error

OpenBrowser opens urlStr in the default browser for the given GOOS value.

func RandomState

func RandomState() string

RandomState returns a random OAuth state value for CSRF protection.

func ServeEmbeddedHTML

func ServeEmbeddedHTML(log *zerolog.Logger, w http.ResponseWriter, filePath string, status int)

ServeEmbeddedHTML serves an embedded HTML page with inline CSS.

func ServeWaitingPage

func ServeWaitingPage(log *zerolog.Logger, w http.ResponseWriter, redirectURL string)

ServeWaitingPage serves the waiting page with the redirect URL injected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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