oauthgoutils

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON = "application/json; charset=utf-8"
)

Variables

This section is empty.

Functions

func FirstNonEmpty

func FirstNonEmpty(vals ...string) string

FirstNonEmpty returns the first non-empty string from the provided values.

func Get

func Get(key, def string) string

Get by default.

func Int64Value added in v0.1.3

func Int64Value(v any) (int64, bool)

Int64Value converts common numeric JSON forms to int64.

func MustRandom

func MustRandom(n int) string

MustRandom panics on error; for places where we already handle outer errors.

func ParseECKey

func ParseECKey(pemBytes []byte) (*ecdsa.PrivateKey, error)

ParseECKey parses PKCS8 or EC private key from PEM bytes.

func RandomStringURLSafe

func RandomStringURLSafe(n int) (string, error)

RandomStringURLSafe returns a URL-safe base64 string (no padding).

func StringValue added in v0.1.3

func StringValue(v any) string

StringValue converts any to string.

func WriteError

func WriteError(w http.ResponseWriter, status int, msg string, err error)

WriteError writes an error response as JSON.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v any)

WriteJSON writes a JSON response.

Types

type ApiError

type ApiError struct {
	Message string `json:"message"`
	Detail  string `json:"detail,omitempty"`
}

ApiError represents an error response.

type PKCE

type PKCE struct {
	// Verifier is a random string used to prove the client is the same that requested the authorization code.
	Verifier string
	// Challenge is the code challenge.
	Challenge string
	// Method is the code challenge method.
	Method string // S256
}

PKCE is a Proof Key for Code Exchange (RFC 7636)

func NewPKCE

func NewPKCE() (*PKCE, error)

NewPKCE creates a new PKCE.

Jump to

Keyboard shortcuts

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