Explosion-Scratch/claude-unofficial-api

CLI Session token

cnpranav opened this issue · 4 comments

I created a file ".claude_key" in a directory where I pasted the session token. When I invoke the command claude --key ./.claude_key from CLI I get the following error -

TypeError: Cannot read properties of undefined (reading 'uuid')
    at Claude.init (file:///opt/homebrew/lib/node_modules/claude-cli/node_modules/claude-ai/index.js:33:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async main (file:///opt/homebrew/lib/node_modules/claude-cli/index.js:82:5)

Is there something that I need to fix or can the key not be in a custom directory?

Your token is probably invalid somehow

Try with the updated code

I updated to the latest code (to execute claude --key ./.claude_key and following error -

Error: { "error": { "type": "permission_error", "message": "We are unable to serve your request" } } at Claude.init (file:///opt/homebrew/lib/node_modules/claude-cli/node_modules/claude-ai/index.js:80:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async main (file:///opt/homebrew/lib/node_modules/claude-cli/index.js:86:5)

When I look at the session key on the website I see the same token that I have in the claude_key file -
image

Have you tried with

claude.fetch = (url, params) => {
    return fetch(url, {
       ...params,
       headers: {
          ...(params.headers || {}),
          // Copy a network request as node.js fetch from the console then paste the headers here
          "User-Agent": // Your user agent
          "referrer": "https://claude.ai/chats",
          "cookie": "entire cookie here, not just the sessionKey"
       },
    })
}