mem0ai/mem0 · error · HTTPException
Refresh token is no longer valid.
Error message
Refresh token is no longer valid.
What it means
Error "Refresh token is no longer valid." thrown in mem0ai/mem0.
Source
Thrown at server/auth.py:81
def create_refresh_token(user_id: str, db: Session) -> str:
expire = datetime.now(timezone.utc) + timedelta(days=REFRESH_TOKEN_EXPIRE_DAYS)
jti = uuid.uuid4()
db.add(RefreshTokenJti(jti=jti, user_id=uuid.UUID(user_id), expires_at=expire))
db.commit()
payload = {"sub": user_id, "exp": expire, "jti": str(jti), "type": "refresh"}
return jwt.encode(payload, _get_secret(), algorithm=JWT_ALGORITHM)
def consume_refresh_jti(jti: str, db: Session) -> None:
"""Atomically mark a refresh token's jti as used. Raises 401 if missing, already used, or expired.
The conditional UPDATE closes the read-check-write race: concurrent replays of the same
token race on a single row, so at most one update affects a row and the rest see rowcount 0.
"""
try:
jti_uuid = uuid.UUID(jti)
except (TypeError, ValueError):
raise HTTPException(status_code=401, detail="Refresh token is no longer valid.")
now = datetime.now(timezone.utc)
result = db.execute(
update(RefreshTokenJti)
.where(
RefreshTokenJti.jti == jti_uuid,
RefreshTokenJti.used_at.is_(None),
RefreshTokenJti.expires_at > now,
)
.values(used_at=now)
)
if result.rowcount == 0:
raise HTTPException(status_code=401, detail="Refresh token is no longer valid.")
db.commit()
def decode_token(token: str) -> dict:
try:
return jwt.decode(token, _get_secret(), algorithms=[JWT_ALGORITHM])View on GitHub (pinned to 001c235229)
Solutions
- Log in again to obtain a new refresh token; the old one was revoked or expired.
When it happens
Trigger: Thrown at server/auth.py:81 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/db48be7c188c00da.
Report an issue: GitHub.