first try at auth before swtiching

This commit is contained in:
2025-08-27 18:01:03 -07:00
parent f4b9f350ae
commit dc5bfcb281
8 changed files with 728 additions and 106 deletions

View File

@@ -5,19 +5,27 @@ import (
"fmt"
"os"
"time"
"github.com/joho/godotenv"
"github.com/sstent/go-garminconnect/internal/api"
"github.com/sstent/go-garminconnect/internal/auth"
)
func main() {
// Verify required environment variables
// Try to load from .env if environment variables not set
if os.Getenv("GARMIN_USERNAME") == "" || os.Getenv("GARMIN_PASSWORD") == "" {
fmt.Println("GARMIN_USERNAME and GARMIN_PASSWORD must be set")
if err := godotenv.Load(); err != nil {
fmt.Println("Failed to load .env file:", err)
}
}
// Verify required credentials
if os.Getenv("GARMIN_USERNAME") == "" || os.Getenv("GARMIN_PASSWORD") == "" {
fmt.Println("GARMIN_USERNAME and GARMIN_PASSWORD must be set in environment or .env file")
os.Exit(1)
}
// Set up authentication client
// Set up authentication client with headless mode enabled
client := auth.NewAuthClient()
token, err := client.Authenticate(
context.Background(),

View File

@@ -19,7 +19,7 @@ func main() {
os.Exit(1)
}
// Create authentication client
// Create authentication client with headless mode enabled
authClient := auth.NewAuthClient()
// Authenticate with credentials