Skip to content

Bug: EnvConfigModal shows Default profile as authenticated but 'Use This Account' fails with invalid token error #365

@johnhenry

Description

@johnhenry

Checklist

  • I searched existing issues and this hasn't been reported

Area

Frontend

Operating System

macOS

Version

2.7.2-beta.10 (also affects 2.7.1)

What happened?

The EnvConfigModal (authentication dialog) shows the "Default" profile as authenticated when the user has a valid Claude Code OAuth token in macOS Keychain. However, when clicking "Use This Account", it fails with error: "Selected profile does not have a valid token".

Root Cause

EnvConfigModal.tsx has inconsistent logic for determining if a profile is authenticated:

  1. Profile Detection (lines 104-106) marks profiles as authenticated if:

    p.oauthToken || (p.isDefault && p.configDir)

    This shows Default profile with Keychain access as ✓ authenticated in the UI.

  2. Token Validation (lines 156-161) when clicking "Use This Account":

    if (\!profile?.oauthToken) {
      setError('Selected profile does not have a valid token');
      return;
    }

    This ONLY accepts profiles with the oauthToken property populated.

  3. The Problem: The Keychain token is available in the backend (get_token_from_keychain() works), but is NOT loaded into profile.oauthToken in the frontend when getClaudeProfiles() is called.

Steps to reproduce

  1. Have a valid Claude Code OAuth token in macOS Keychain (from claude setup-token)
  2. Launch Auto-Claude v2.7.1+ (fresh install with no prior config)
  3. Try to use a feature requiring authentication (e.g., Ideation)
  4. EnvConfigModal appears showing "Default" profile as authenticated
  5. Click "Use This Account" button
  6. Error appears: "Selected profile does not have a valid token"
Image

Expected behavior

When getClaudeProfiles() is called for a Default profile with configDir (Keychain access):

  • The backend should call get_token_from_keychain() to retrieve the token
  • Populate the oauthToken field in the returned profile data
  • Frontend can then successfully use the profile when clicking "Use This Account"

Workaround

Users must manually enter the token via "Enter token manually" section.

Proposed Fix

Modify the backend IPC handler for getClaudeProfiles to:

  1. Detect when a profile is Default with configDir but no oauthToken
  2. Call get_token_from_keychain() (from apps/backend/core/auth.py)
  3. Populate the oauthToken field in the profile response

Impact

  • Users with valid Keychain tokens cannot authenticate via the UI
  • Confusing UX: Shows as "authenticated" but fails when trying to use it
  • Affects macOS users exclusively (Keychain is macOS-only)

Related

Technical Context

Files involved:

  • apps/frontend/src/renderer/components/EnvConfigModal.tsx (frontend UI logic)
  • apps/backend/core/auth.py (Keychain token retrieval)
  • Backend IPC handler for getClaudeProfiles (needs modification)

I'll submit a PR with the fix shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions