"use client"; import { useState } from "react"; import PropTypes from "prop-types"; import { Modal, Button, Input } from "@/shared/components"; import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard"; /** * Cursor Auth Modal * Import token from Cursor IDE's local SQLite database * * Token Location: * - Linux: ~/.config/Cursor/User/globalStorage/state.vscdb * - macOS: /Users//Library/Application Support/Cursor/User/globalStorage/state.vscdb * - Windows: %APPDATA%\Cursor\User\globalStorage\state.vscdb * * Database Keys: * - cursorAuth/accessToken: The access token * - storage.serviceMachineId: Machine ID for checksum */ export default function CursorAuthModal({ isOpen, onSuccess, onClose }) { const [accessToken, setAccessToken] = useState(""); const [machineId, setMachineId] = useState(""); const [error, setError] = useState(null); const [importing, setImporting] = useState(false); const { copied, copy } = useCopyToClipboard(); const handleImportToken = async () => { if (!accessToken.trim()) { setError("Please enter an access token"); return; } if (!machineId.trim()) { setError("Please enter a machine ID"); return; } setImporting(true); setError(null); try { const res = await fetch("/api/oauth/cursor/import", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ accessToken: accessToken.trim(), machineId: machineId.trim(), }), }); const data = await res.json(); if (!res.ok) { throw new Error(data.error || "Import failed"); } // Success - close modal and trigger refresh onSuccess?.(); onClose(); } catch (err) { setError(err.message); } finally { setImporting(false); } }; const linuxCommand = `sqlite3 ~/.config/Cursor/User/globalStorage/state.vscdb "SELECT key, value FROM itemTable WHERE key IN ('cursorAuth/accessToken', 'storage.serviceMachineId')"`; const macCommand = `sqlite3 "/Users/$USER/Library/Application Support/Cursor/User/globalStorage/state.vscdb" "SELECT key, value FROM itemTable WHERE key IN ('cursorAuth/accessToken', 'storage.serviceMachineId')"`; return (
{/* Info Box */}
info

Prerequisites

Make sure you are logged in to Cursor IDE first. Tokens are stored in the local SQLite database.

{/* Instructions */}

How to get your tokens:

Linux:

{linuxCommand}

macOS:

{macCommand}

Database locations:

  • Linux: ~/.config/Cursor/User/globalStorage/state.vscdb
  • macOS: /Users/<user>/Library/Application Support/Cursor/User/globalStorage/state.vscdb
  • Windows: %APPDATA%\Cursor\User\globalStorage\state.vscdb
{/* Access Token Input */}