auth

package
v0.0.0-...-90d3ee0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package auth implements Garmin SSO login and token persistence.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMFARequired = errors.New("mfa required")
)
View Source
var ErrNotAuthenticated = errors.New("not authenticated (run `garmin auth login`)")

Functions

func Logout

func Logout(configDir, profile string) error

func SaveSession

func SaveSession(configDir, profile string, s *Session) error

Types

type OAuth1Token

type OAuth1Token struct {
	OAuthToken       string `json:"oauth_token"`
	OAuthTokenSecret string `json:"oauth_token_secret"`
	MFAToken         string `json:"mfa_token,omitempty"`
	Domain           string `json:"domain,omitempty"`
}

type OAuth2Token

type OAuth2Token struct {
	Scope                 string `json:"scope"`
	JTI                   string `json:"jti"`
	TokenType             string `json:"token_type"`
	AccessToken           string `json:"access_token"`
	RefreshToken          string `json:"refresh_token"`
	ExpiresIn             int    `json:"expires_in"`
	ExpiresAt             int64  `json:"expires_at"`
	RefreshTokenExpiresIn int    `json:"refresh_token_expires_in"`
	RefreshTokenExpiresAt int64  `json:"refresh_token_expires_at"`
}

func RefreshOAuth2

func RefreshOAuth2(ctx context.Context, configDir string, oauth1 OAuth1Token) (OAuth2Token, error)

RefreshOAuth2 exchanges the OAuth1 token for a fresh OAuth2 token.

func (OAuth2Token) Expired

func (t OAuth2Token) Expired(now time.Time) bool

type Session

type Session struct {
	OAuth1 OAuth1Token
	OAuth2 OAuth2Token
}

Session contains OAuth credentials needed to call connectapi.garmin.com.

func LoadSession

func LoadSession(configDir, profile string) (*Session, error)

func Login

func Login(ctx context.Context, configDir, email, password string, promptMFA func() (string, error)) (*Session, error)

Login performs the full SSO → OAuth1 → OAuth2 flow.

Jump to

Keyboard shortcuts

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