Skip to content

OAuth in-app login fails to save provider/account data (macOS) #133

@zhang588

Description

@zhang588

Bug Description

After completing OAuth login for Qwen AI (International) and Z.ai through the in-app login window, the provider and account data are not saved to data.json. The provider management page shows no newly added providers.

Environment

  • Chat2API version: 1.3.0
  • OS: macOS (Apple Silicon)
  • Electron: bundled version

Steps to Reproduce

  1. Open Chat2API
  2. Go to Provider Management → Add Provider → Select "Qwen AI (International)"
  3. Complete OAuth login in the popup window (Google login → chat.qwen.ai)
  4. Close the login window after successful authentication
  5. Check Provider Management page

Expected: Qwen AI (International) appears in the provider list with the account
Actual: Provider does not appear. Decrypting data.json confirms providers and accounts arrays remain empty/unchanged.

Additional Details

Issue 1: OAuth token extraction failure

The OAuth window creates a browser partition under ~/Library/Application Support/chat2api/Partitions/oauth-* and cookies are saved correctly (including the JWT token in cookies). However, the token is not extracted from localStorage (where the app looks for it via TOKEN_EXTRACTION_CONFIGS["qwen-ai"].tokenSources). The page may not have fully loaded the token into localStorage before extraction runs.

Older sessions (earlier partitions) do have the token key in localStorage, but newer ones sometimes don't — suggesting a race condition.

Issue 2: Z.ai OAuth creates guest accounts

When using the in-app OAuth window for Z.ai (chat.z.ai), the login flow creates guest accounts (guest-xxx@guest.com) instead of completing the Google OAuth flow. The ZaiAdapter then rejects these tokens as guest accounts.

Workaround

Manually decrypt data.json (using the conf v14 encryption: aes-256-cbc + pbkdf2Sync), inject the provider and account objects, re-encrypt, and restart the app.

Alternatively, obtain the JWT token from the browser's LocalStorage (F12 → Application → Local Storage) and use the "manual token" input — though the paste functionality in the token input field also has issues on macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions