Skip to content

fix(auth): honor NOTION_TOKEN in auth status and doctor#62

Open
timqi wants to merge 1 commit into
4ier:mainfrom
timqi:fix/auth-status-env-token
Open

fix(auth): honor NOTION_TOKEN in auth status and doctor#62
timqi wants to merge 1 commit into
4ier:mainfrom
timqi:fix/auth-status-env-token

Conversation

@timqi

@timqi timqi commented Jul 8, 2026

Copy link
Copy Markdown

Problem

When authenticating solely via the NOTION_TOKEN environment variable (no notion auth login), notion auth status reports ✗ Not authenticated and notion auth doctor reports no token found, even though other commands such as notion user me work correctly.

This regressed with the multi-profile refactor — 0.3 was unaffected, 0.7 is.

Root cause

auth status and auth doctor read the token directly from the config file (cfg.GetCurrentProfile() / cfg.Token), bypassing the shared getToken() helper (cmd/root.go) that every other command uses. getToken() resolves the token with env-first precedence (NOTION_TOKEN → config profile), so env-only auth was invisible to these two commands.

Fix

Route both auth status and auth doctor through getToken(), so env-var auth is recognized consistently. Also surface the token source (NOTION_TOKEN env vs profile) in the output. Config-based profile details are only shown when a config file is actually in use.

Verification

Built a fresh binary and exercised each path:

Scenario Result
NOTION_TOKEN set (valid) ✓ Authenticated, Source: NOTION_TOKEN env
NOTION_TOKEN set (invalid) correctly reports token is invalid (was: Not authenticated)
config file only, no env ✓ Authenticated, profile details as before
no token at all ✗ Not authenticated

go build, go vet, and go test ./cmd (18 passed) all green.

🤖 Generated with Claude Code

auth status and auth doctor read the token directly from the config
file, bypassing the NOTION_TOKEN environment variable that every other
command resolves via getToken(). As a result, authenticating solely
through NOTION_TOKEN made 'auth status' report '✗ Not authenticated'
(and 'auth doctor' report 'no token found') even though commands like
'user me' worked fine. This regressed with the multi-profile refactor;
0.3 was unaffected.

Route both commands through getToken() so env-var auth is recognized,
and surface the token source (NOTION_TOKEN env vs profile).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant