Skip to content

V2 API returns 429 rate limit during client.connect() after fresh OAuth flow #33

@kozy-codes

Description

@kozy-codes

Problem

After successfully completing OAuth flow and obtaining a fresh access token, the V2 API authentication fails with a 429 rate limit error during client.connect().

Steps to Reproduce

  1. Run ticktick-sdk auth --manual with fresh OAuth credentials
  2. Successfully complete OAuth flow → obtain new access token
  3. Set environment variables with new credentials:
    • TICKTICK_CLIENT_ID
    • TICKTICK_CLIENT_SECRET
    • TICKTICK_ACCESS_TOKEN (fresh token)
    • TICKTICK_USERNAME
    • TICKTICK_PASSWORD
  4. Initialize client: client = TickTickClient.from_settings()
  5. Call await client.connect()

Error

Failed to initialize V2 client: Authentication failed:  | Details: {'status_code': 429, 'response': '', 'requires_2fa': False}

TickTickConfigurationError: Both V1 and V2 APIs are required. V2 initialization failed: Authentication failed:  | Details: {'status_code': 429, 'response': '', 'requires_2fa': False}; V2 authentication verification failed

Full Traceback

Traceback (most recent call last):
  File "/Users/kj/clawd/skills/ticktick/scripts/tt.py", line 265, in <module>
    asyncio.run(main())
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
  File "/Users/kj/clawd/skills/ticktick/scripts/tt.py", line 221, in main
    await tasks_today()
  File "/Users/kj/clawd/skills/ticktick/scripts/tt.py", line 106, in tasks_today
    await tasks_for_date(date.today(), "today")
  File "/Users/kj/clawd/skills/ticktick/scripts/tt.py", line 58, in tasks_for_date
    await client.connect()
  File "/Users/kj/agents/ticktick-sdk/src/ticktick_sdk/client/client.py", line 131, in connect
    await self._api.initialize()
  File "/Users/kj/agents/ticktick-sdk/src/ticktick_sdk/unified/api.py", line 336, in initialize
    raise TickTickConfigurationError(...)

Context

  • V1 OAuth completed successfully
  • Fresh access token obtained via ticktick-sdk auth --manual
  • 429 error occurs specifically during V2 API authentication/verification
  • Happens immediately after OAuth flow (within seconds)

Expected Behavior

Client should initialize successfully with fresh credentials, or provide clearer error messaging about rate limits and retry strategy.

Questions

  1. Should there be retry logic with exponential backoff for 429 errors during initialization?
  2. Is the V2 authentication hitting rate limits because we just completed OAuth flow moments before?
  3. Should the SDK cache/reuse authentication to avoid hitting limits during rapid reconnects?

Environment

  • Python: 3.12
  • ticktick-sdk: latest from local clone (/Users/kj/agents/ticktick-sdk)
  • OS: 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