{"record":{"id":"64a30b5539d849c1","repo":"warpdotdev/warp","slug":"your-credentials-are-invalid-please-log-in-again","errorCode":null,"errorMessage":"Your credentials are invalid. Please log in again with `{cli_name} login`.","messagePattern":"Your credentials are invalid\\. Please log in again with `(.+?) login`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/mod.rs","lineNumber":1709,"sourceCode":"        if dispatched {\n            return;\n        }\n        match event {\n            AuthManagerEvent::AuthComplete => {\n                dispatched = true;\n                if let Err(err) = dispatch_command(ctx, command.clone(), global_options.clone()) {\n                    report_fatal_error(err, ctx);\n                }\n            }\n            AuthManagerEvent::NeedsReauth => {\n                dispatched = true;\n                let auth_state = AuthStateProvider::handle(ctx).as_ref(ctx).get();\n                let message = if auth_state.is_api_key_authenticated() {\n                    \"Your API key is invalid. Please provide a valid key via '--api-key' or the WARP_API_KEY environment variable.\".to_string()\n                } else {\n                    format!(\"Your credentials are invalid. Please log in again with `{cli_name} login`.\")\n                };\n                report_fatal_error(anyhow::anyhow!(message), ctx);\n            }\n            AuthManagerEvent::AuthFailed(err) => {\n                dispatched = true;\n                report_fatal_error(anyhow::anyhow!(\"Authentication failed: {err:#}\"), ctx);\n            }\n            _ => {}\n        }\n    });\n\n    // Trigger authentication - the subscription above will handle the result.\n    AuthManager::handle(ctx).update(ctx, |auth_manager, ctx| match authentication {\n        CommandAuthentication::PendingApiKey(api_key) => {\n            auth_manager.authenticate_api_key(api_key, ctx);\n        }\n        CommandAuthentication::RefreshUser => auth_manager.refresh_user(ctx),\n    });\n}\n","sourceCodeStart":1691,"sourceCodeEnd":1727,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/mod.rs#L1691-L1727","documentation":"The AuthManager emitted NeedsReauth for an interactive (non-API-key) session: the persisted OAuth credentials can no longer be refreshed — the refresh token expired or was revoked — so the only remedy is to log in again. Selected when the auth state is not API-key authenticated.","triggerScenarios":"Running auth-required commands after the stored session's refresh token expired, after a password change, after revoking sessions from account security settings, or after the credential store was wiped.","commonSituations":"Long-lived local or CI sessions past the refresh-token lifetime; account security actions that invalidate sessions; switching accounts without logging out first.","solutions":["Run `warp login` again to establish a fresh session","If login loops back to this error, run `warp logout` first, then log in","For headless environments, switch to WARP_API_KEY authentication instead of a session"],"exampleFix":"# before\nwarp agent list   # stale session -> credentials invalid\n\n# after\nwarp logout || true\nwarp login\nwarp agent list","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out=$(warp agent list 2>&1) || { case \"$out\" in\n  *'credentials are invalid'*|*'not logged in'*) warp logout; warp login && warp agent list ;;\n  *) echo \"$out\" >&2; exit 1 ;;\nesac; }","preventionTips":["Prefer WARP_API_KEY for headless and long-lived automation","Re-login on a schedule shorter than the refresh-token lifetime","Wrap session-dependent jobs with a login-retry step"],"tags":["authentication","session","credentials"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}