Skip to content
Latchkey

fastlane session expired / 2FA required for App Store Connect in CI

fastlane logged in with an Apple ID and the two-factor session that backs it has expired or is being requested interactively. CI cannot answer a 2FA prompt, so the right fix is to authenticate with an App Store Connect API key, which needs no session and no code.

What this error means

pilot, deliver, or spaceship fails with "Your session expired, please log in again" or stalls asking for a verification code. It often appears weeks after a FASTLANE_SESSION cookie was captured.

fastlane
[!] Your session expired, please log in again to continue.
fastlane requires a verification code to log in with this Apple ID, but none can be
entered in a non-interactive environment.

Common causes

A captured 2FA session cookie expired

FASTLANE_SESSION holds a time-limited cookie. Once it lapses, the next run is treated as a fresh login that needs a 2FA code CI cannot provide.

Apple ID auth needs an interactive verification code

Without a stored session, spaceship must complete two-factor, which is impossible in a headless job.

How to fix it

Switch to an App Store Connect API key

  1. Create an App Store Connect API key with App Manager access.
  2. Configure fastlane to use it so no Apple ID session is needed.
  3. Run pilot / deliver, which then authenticate without 2FA.
Fastfile
app_store_connect_api_key(
  key_id: ENV["ASC_KEY_ID"],
  issuer_id: ENV["ASC_ISSUER_ID"],
  key_filepath: "AuthKey_#{ENV['ASC_KEY_ID']}.p8"
)

Refresh the session only if a key is impossible

If you must use an Apple ID, regenerate FASTLANE_SESSION with fastlane spaceauth and update the secret. The cookie is temporary and will expire again.

Terminal
fastlane spaceauth -u appleid@example.com

How to prevent it

  • Prefer App Store Connect API keys for all CI authentication.
  • Avoid relying on FASTLANE_SESSION cookies in long-lived pipelines.
  • Reserve Apple ID logins for interactive use only.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →