{"record":{"id":"aa708c29db97dc18","repo":"mem0ai/mem0","slug":"invalid-or-expired-token","errorCode":null,"errorMessage":"Invalid or expired token.","messagePattern":"Invalid or expired token\\.","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"server/auth.py","lineNumber":101,"sourceCode":"    result = db.execute(\n        update(RefreshTokenJti)\n        .where(\n            RefreshTokenJti.jti == jti_uuid,\n            RefreshTokenJti.used_at.is_(None),\n            RefreshTokenJti.expires_at > now,\n        )\n        .values(used_at=now)\n    )\n    if result.rowcount == 0:\n        raise HTTPException(status_code=401, detail=\"Refresh token is no longer valid.\")\n    db.commit()\n\n\ndef decode_token(token: str) -> dict:\n    try:\n        return jwt.decode(token, _get_secret(), algorithms=[JWT_ALGORITHM])\n    except JWTError:\n        raise HTTPException(status_code=401, detail=\"Invalid or expired token.\")\n\n\nbearer_scheme = HTTPBearer(auto_error=False)\napi_key_header = APIKeyHeader(name=\"X-API-Key\", auto_error=False)\n\n\ndef _mark_auth_type(request: Request, auth_type: str) -> None:\n    request.state.auth_type = auth_type\n\n\ndef _get_default_user(db: Session) -> User | None:\n    return db.scalar(select(User).order_by(User.created_at.asc()))\n\n\ndef _resolve_user_from_jwt(token: str, db: Session) -> User:\n    payload = decode_token(token)\n    if payload.get(\"type\") != \"access\":\n        raise HTTPException(status_code=401, detail=\"Invalid token type.\")","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/server/auth.py#L83-L119","documentation":"Error \"Invalid or expired token.\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at server/auth.py:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log in again; the access token is invalid or expired. Use the refresh flow if available."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}