Skip to content

auth refresh prints token bytes to stdout instead of refreshing #19

Closed

Description

@DTTerastar

Severity

major

Summary

withings-export auth refresh is documented as "Force a token refresh and report status". In practice it just prints the first 20 chars of the access token to stdout and exits — it does not force a refresh, and it leaks token material into the user's scrollback / any captured logs.

Reproduce

$ withings-export auth refresh
Token valid: deb1cd0c847bec8edbe3...

Source (cmd/auth.go):

var refreshCmd = &cobra.Command{
    Use:   "refresh",
    Short: "Force a token refresh and report status",
    RunE: func(cmd *cobra.Command, args []string) error {
        token, err := auth.GetToken()
        if err != nil { return err }
        fmt.Printf("Token valid: %s...\n", token[:min(20, len(token))])
        return nil
    },
}

auth.GetToken() only refreshes if the cached token is within ~5 min of expiry; calling auth refresh on a token with hours of life left is a no-op masquerading as a refresh.

Expected

  • Issue an explicit OAuth refresh against Withings (not a passive GetToken()), regardless of expiry.
  • Print a status line to stdout that does NOT include any token bytes — e.g. refreshed; new token expires 2026-04-25T19:00:00-04:00 (matching auth status's format).
  • Send progress to stderr if applicable; stdout stays one machine-friendly line.

Severity rationale

Major rather than blocker because the export commands themselves do refresh transparently when needed; this only affects users who explicitly run auth refresh to debug. The token-leak aspect bumps it above minor.

Activity

  1. DTTerastar commented on Apr 25, 2026

    @DTTerastar
    ContributorAuthor

    Confirmed still reproduces against HEAD b580683: /tmp/qa-bin/withings-export auth refresh -> Token valid: <REDACTED 20-char token prefix>... and exit 0. Token bytes leaked to stdout, refresh not actually forced (token has hours of life left).

  2. DTTerastar commented on Apr 26, 2026

    @DTTerastar
    ContributorAuthor

    @claude I think we should just remove refresh since the code should just do that automatically. It doesn't make sense as a cli command

  3. claude commented on Apr 26, 2026

    @claude

    Claude finished @DTTerastar's task in 1m 1s —— View job • claude/issue-19-20260426-0004 • Create PR ➔


    Removing auth refresh subcommand

    • Read relevant source files
    • Remove the refreshCmd from cmd/auth.go
    • Update statusCmd error message and long description (removed references to auth refresh)
    • Commit and push changes

    Removed the auth refresh subcommand entirely from cmd/auth.go. Changes:

    • Deleted refreshCmd variable (was leaking token bytes to stdout and not actually forcing a refresh)
    • Removed authCmd.AddCommand(refreshCmd) from init()
    • Updated the statusCmd long description: replaced "Use 'auth refresh' (or any export subcommand) to actually refresh" → "Any export subcommand will refresh automatically when needed"
    • Updated the statusCmd error message for an expired token: auth refresh → auth login
  4. DTTerastar commented on Apr 26, 2026

    @DTTerastar
    ContributorAuthor

    @claude Did you make a PR? Always PR in fixes! PR in whatever we need to make sure you do that in the future as well!

  5. claude commented on Apr 26, 2026

    @claude

    Claude finished @DTTerastar's task in 1m 47s —— View job • claude/issue-19-20260426-0009 • Create PR ➔


    Fixing issue #19 and creating PR

    • Check for existing PRs and read CLAUDE.md
    • Implement the fix (remove auth refresh subcommand)
    • Commit and push changes
    • Create CLAUDE.md to always create PRs for fixes

    The gh pr create command wasn't approved, but everything is pushed. Please create the PR using the link below.

    Changes made:

    • Removed refreshCmd from cmd/auth.go — it leaked token bytes to stdout and didn't force a real refresh
    • Updated statusCmd long description and expired-token error to remove references to auth refresh → now points to auth login
    • Created CLAUDE.md so future Claude runs know to always open a PR after implementing changes

    • claude/issue-19-20260426-0009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions