auth

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(ctx context.Context, clientId, clientSecret, redirectUrl, authEndpoint, redirectPort, consoleUrl string) (*oauth2.Token, error)

func CheckTokenExpiry added in v0.2.1

func CheckTokenExpiry(token *oauth2.Token) error

func ClearTokens

func ClearTokens() error

ClearTokens removes all stored tokens

func LoadToken

func LoadToken(provider string) (*oauth2.Token, error)

LoadToken loads token information from disk

func OpenBrowser

func OpenBrowser(url string) error

func SaveToken

func SaveToken(token *oauth2.Token, provider string) error

SaveToken saves the token information to disk

Types

type AuthError

type AuthError struct {
	Code    ErrorCode
	Message string
	Cause   error
}

AuthError represents authentication-related errors

func NewAuthError

func NewAuthError(code ErrorCode, message string) *AuthError

func NewAuthErrorWithCause

func NewAuthErrorWithCause(code ErrorCode, message string, cause error) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

type AuthResult

type AuthResult struct {
	Token *Token
	Error error
}

type Client

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

func NewClient

func NewClient(authendpoint, clientID, clientSecret, redirectURL string) *Client

type ErrorCode

type ErrorCode int
const (
	ErrUnsupportedProvider ErrorCode = iota
	ErrTokenStorage
	ErrAuthFlow
	ErrTokenExpired
	ErrInvalidToken
	ErrNetworkError
)

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	Expiry       time.Time
}

type TokenInfo

type TokenInfo struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	IDToken      string    `json:"id_token,omitempty"`
	TokenType    string    `json:"token_type"`
	ExpiresAt    time.Time `json:"expires_at"`
	ExpiresIn    int64     `json:"expires_in,omitempty"`
	Scopes       []string  `json:"scopes"`
	Provider     string    `json:"provider"`
}

Jump to

Keyboard shortcuts

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