Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Kiro CLI Login Issues and Token Refresh Failures

Open shanel-10x opened this issue 6 months ago • 10 comments

Before opening, please confirm:

Operating System

MacOS 26.5.1

Kiro Version

2.5.1

Bug Description

There are similar issues to this. However none seem exactly the same. There are one's talking about eager login expiry, the login process being iffy

Bug Report: Kiro CLI requires login on every new session

Summary

Each new Kiro CLI terminal session requires re-authentication, even when already logged in from another window.

Environment

  • OS: macOS (Apple Silicon)
  • Date: 2026-06-02

Actual Behavior

Every new terminal window running kiro-cli chat prompts for login, regardless of existing authenticated sessions.

Investigation Findings

Auth tokens are stored in a shared SQLite database:

  • Location: ~/Library/Application Support/kiro-cli/data.sqlite3
  • Table: auth_kv
  • Key: kirocli:external-idp:token

The shared storage infrastructure exists, but new sessions do not appear to pick up the existing valid token. No entry was found in the macOS Keychain for "kiro".

Possible Causes

  1. Token expiration without refresh — Only a short-lived access token is stored, with no refresh token to renew it silently.
  2. Missing token validation on startup — The CLI may not check auth_kv for an existing valid token before prompting login.
  3. Database lock contention — Session .lock files may prevent concurrent reads of the auth database.

Steps to Reproduce

  1. Open a terminal and run kiro-cli chat
  2. Complete the login flow
  3. Open a second terminal and run kiro-cli chat
  4. Observe: login is required again despite step 2

Expected Behavior

Logging in once should persist across all concurrent and subsequent CLI sessions without requiring re-authentication. In addition when the login expires the cli shouldn't just hang it should prompt the user to reauthenticate.

Conversation ID

No response

Additional Context

No response

shanel-10x avatar Jun 03 '26 06:06 shanel-10x

🤖 Potential Duplicate Detected

This issue appears to be similar to:

What happens next?

  • ⏰ This issue will be automatically closed in 3 days
  • 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
  • 💬 Comment on the original issue if you have additional information

Why is this marked as duplicate? Both report authentication issues with Kiro CLI on macOS, involving problems with login persistence and token management across sessions

github-actions[bot] avatar Jun 03 '26 06:06 github-actions[bot]

Those issues are either not specific to the kiro-cli or not the same

shanel-10x avatar Jun 03 '26 06:06 shanel-10x

Thank you for your feedback! 🙏

The duplicate label has been removed and this issue has been sent back for maintainer review.

A maintainer will review this issue shortly.

github-actions[bot] avatar Jun 03 '26 06:06 github-actions[bot]

Hi @shanel-10x,

Thanks for raising this! We've marked it as a bug and will investigate further. Your investigation into the SQLite auth storage is helpful context for the fix.

AnilMaktala avatar Jun 03 '26 14:06 AnilMaktala

Hey @shanel-10x could you provide a trace log file? It sounds like kiro-cli does not have permissions to write to your macOS keychain, which is required as part of authentication.

export KIRO_LOG_LEVEL=trace
kiro-cli login

# Log file on macOS at $TMPDIR/kirocli-log/cli.log

brandonskiser avatar Jun 03 '26 16:06 brandonskiser

@brandonskiser

Unless I'm misunderstanding where that log file is:

export KIRO_LOG_LEVEL=trace
kiro-cli login

error: Already logged in, please logout with kiro-cli logout first
→  ~ cat $TMPDIR/kirocli-log/cli.log
cat: /var/folders/4w/4cc91nmn3h33x4771p4cp_0w0000gp/T//kirocli-log/cli.log: No such file or directory

Then immediately after it tells me it's logged in

→ ~ kiro-cli
  You are not logged in. Login now?
❯ Yes
  No

shanel-10x avatar Jun 04 '26 06:06 shanel-10x

Apologies @shanel-10x , there was a bug it seems with logging around this flow that should be resolved in the latest version. The log file will be at $TMPDIR/kiro-log/cli.log

brandonskiser avatar Jun 11 '26 19:06 brandonskiser

@brandonskiser Doesn't appear to be.

→ ~ kiro-cli --version
kiro-cli 2.6.1
→ ~ kiro-cli login
error: Already logged in, please logout with kiro-cli logout first
→ ~ cat $TMPDIR/kirocli-log/cli.log
cat: /var/folders/4w/4cc91nmn3h33x4771p4cp_0w0000gp/T//kirocli-log/cli.log: No such file or directory

shanel-10x avatar Jun 12 '26 06:06 shanel-10x

@shanel-10x It looks like you're still using the kirocli-log path, can you try checking $TMPDIR/kiro-log/cli.log?

brandonskiser avatar Jun 12 '26 16:06 brandonskiser

Today I had a similar issue and I found that using the sqlite3 query ".recover" multi-step process to recover the database addressed my issue.

cloudnativeengineer avatar Jul 16 '26 21:07 cloudnativeengineer