jahwag / ClaudeSync

ClaudeSync is a Python tool that automates the synchronization of local files with Claude.ai Projects
MIT License
165 stars 24 forks source link

Received a 403 Forbidden error. Your session key might be invalid. Please try logging out and logging in again.... #42

Closed sintetico82 closed 1 month ago

sintetico82 commented 1 month ago

Describe the bug

Unable to login, i am tring put session key and the expiration date (that I have to convert in this format reading the code "%a, %d %b %Y %H:%M:%S %Z") but I am unable to login.

log:

Please enter your sessionKey: sk-ant-sid01-xxx Please enter the expires time for the sessionKey [Fri, 06 Sep 2024 16:05:52 UTC]: Thu, 06 Sep 2024 15:57:41 UTC 2024-08-07 18:06:00,628 - DEBUG - Making GET request to https://api.claude.ai/api/organizations 2024-08-07 18:06:00,629 - DEBUG - Headers: {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', 'Origin': 'https://claude.ai', 'Referer': 'https://claude.ai/projects', 'Accept': '/', 'Accept-Encoding': 'gzip, deflate, zstd', 'Accept-Language': 'en-US,en;q=0.5', 'anthropic-client-sha': 'unknown', 'anthropic-client-version': 'unknown', 'Connection': 'keep-alive', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin'} 2024-08-07 18:06:00,629 - DEBUG - Cookies: {'sessionKey': 'sk-ant-sid01-xxx', 'CH-prefers-color-scheme': 'dark', 'anthropic-consent-preferences': '{"analytics":true,"marketing":true}'} 2024-08-07 18:06:00,718 - DEBUG - Response status code: 403 2024-08-07 18:06:00,718 - DEBUG - Response headers: {'Date': 'Wed, 07 Aug 2024 16:06:00 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': '__cf_bm=jpJuL97L72xH1OMbJvti3egvAuiY3m5hfICZWWK1m7g-1723046760-1.0.1.1-6VCqgVrjlheYNwbj1WMq3gIeUGyUWQIwT7ZO0B9nkErsKqXef2auKMEioSP3M5ZG9.XIhHrmUaqDb.mSTv2TJw; path=/; expires=Wed, 07-Aug-24 16:36:00 GMT; domain=.claude.ai; HttpOnly; Secure; SameSite=None', 'Vary': 'Accept-Encoding', 'Server': 'cloudflare', 'CF-RAY': '8af882ee5e88374e-MXP', 'Content-Encoding': 'gzip', 'alt-svc': 'h3=":443"; ma=86400'} 2024-08-07 18:06:00,719 - DEBUG - Response content: {"error":{"message":"We are unable to serve your request","type":"permission_error"}}... 2024-08-07 18:06:00,719 - ERROR - Received a 403 Forbidden error. Your session key might be invalid. Please try logging out and logging in again. If the issue persists, you can try using the claude.ai-curl provider as a workaround:

jahwag commented 1 month ago

Have you tried the claude.ai-curl provider? https://github.com/jahwag/ClaudeSync/wiki/Troubleshooting#1-authentication-failures

sintetico82 commented 1 month ago

Yes, same error...

claudesync api login claude.ai-curl To obtain your session key, please follow these steps:

  1. Open your web browser and go to https://claude.ai
  2. Log in to your Claude account if you haven't already
  3. Once logged in, open your browser's developer tools:
    • Chrome/Edge: Press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac)
    • Firefox: Press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac)
    • Safari: Enable developer tools in Preferences > Advanced, then press Cmd+Option+I
  4. In the developer tools, go to the 'Application' tab (Chrome/Edge) or 'Storage' tab (Firefox)
  5. In the left sidebar, expand 'Cookies' and select 'https://claude.ai'
  6. Locate the cookie named 'sessionKey' and copy its value. Ensure that the value is not URL-encoded. Please enter your sessionKey: sk-ant-sid01-xxx Please enter the expires time for the sessionKey [Fri, 06 Sep 2024 16:26:38 UTC]: Thu, 06 Sep 2024 15:57:41 UTC 2024-08-07 18:26:50,243 - DEBUG - Executing command: curl https://api.claude.ai/api/organizations --compressed -s -S -w %{http_code} -H User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 -H Cookie: sessionKey=sk-ant-sid01-xxx -H Content-Type: application/json 2024-08-07 18:26:50,335 - ERROR - cURL command failed with return code 43. stdout: 000, stderr: curl: (43) A libcurl function was given a bad argument . Request headers: ['-H', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', '-H', 'Cookie: sessionKey=sk-ant-sid01-xxx', '-H', 'Content-Type: application/json'] cURL command failed with return code 43. stdout: 000, stderr: curl: (43) A libcurl function was given a bad argument . Request headers: ['-H', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', '-H', 'Cookie: sessionKey=sk-ant-sid01-xxx', '-H', 'Content-Type: application/json'] Failed to retrieve organizations. Please enter a valid sessionKey.
sintetico82 commented 1 month ago

EDIT:

I can login with WLS, i can listen my remote files, view organization and project name, but sync operation failed:

2024-08-07 19:06:59,910 - DEBUG - Executing command: curl https://api.claude.ai/api/organizations/65a880de-0c66-4b7b-9472-e2ea9fcdd079/projects/095b442b-4e32-4ab3-aaf4-9ad8cd6d6087/docs --compressed -s -S -w %{http_code} -H User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 -H Cookie: sessionKey=sk-ant-sid01-xxx -H Content-Type: application/json 2024-08-07 19:07:00,263 - DEBUG - Got HTTP 200 Local → Remote: 0%| | 0/279 [00:00<?, ?it/s2024-08-07 19:08:42,849 - DEBUG - Executing command: curl https://api.claude.ai/api/organizations/65a880de-0c66-4b7b-9472-e2ea9fcdd079/projects/095b442b-4e32-4ab3-aaf4-9ad8cd6d6087/docs --compressed -s -S -w %{http_code} -H User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 -H Cookie: sessionKey=sk-ant-sid01-xxx -H Content-Type: application/json -X POST -d {"file_name": ".gitattributes", "content": "###############################################################################\n# Set default behavior to automatically normalize line endings.\n###############################################################################\n text=auto\n\n###############################################################################\n# Set default behavior for command prompt diff.\n#\n# This is need for earlier builds of msysgit that does not have it on by\n# default for csharp files.\n# Note: This is only used by command line\n###############################################################################\n#.cs diff=csharp\n\n###############################################################################\n# Set the merge driver for project and solution files\n#\n# Merging from the command prompt will add diff markers to the files if there\n# are conflicts (Merging from VS is not affected by the settings below, in VS\n# the diff markers are never inserted). Diff markers may cause the following \n# file extensions to fail to load in VS. An alternative would be to treat\n# these files as binary and thus will always conflict and require user\n# intervention with every merge. To do so, just uncomment the entries below\n###############################################################################\n#.sln merge=binary\n#.csproj merge=binary\n#.vbproj merge=binary\n#.vcxproj merge=binary\n#.vcproj merge=binary\n#.dbproj merge=binary\n#.fsproj merge=binary\n#.lsproj merge=binary\n#.wixproj merge=binary\n#.modelproj merge=binary\n#.sqlproj merge=binary\n#.wwaproj merge=binary\n\n###############################################################################\n# behavior for image files\n#\n# image files are treated as binary by default.\n###############################################################################\n#.jpg binary\n#.png binary\n#.gif binary\n\n###############################################################################\n# diff behavior for common document formats\n# \n# Convert binary document formats to text before diffing them. This feature\n# is only available from the command line. Turn it on by uncommenting the \n# entries below.\n###############################################################################\n#.doc diff=astextplain\n#.DOC diff=astextplain\n#.docx diff=astextplain\n#.DOCX diff=astextplain\n#.dot diff=astextplain\n#.DOT diff=astextplain\n#.pdf diff=astextplain\n#.PDF diff=astextplain\n#.rtf diff=astextplain\n#*.RTF diff=astextplain\n"} 2024-08-07 19:08:43,001 - DEBUG - Got HTTP 403 2024-08-07 19:08:43,001 - ERROR - HTTP request failed with status code 403. Response content: {"error":{"message":"We are unable to serve your request","type":"permission_error"}}. Request headers: ['-H', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', '-H', 'Cookie: sessionKey=sk-ant-sid01-xxx', '-H', 'Content-Type: application/json'] Local → Remote: 0%| | 0/279 [00:00<?, ?it/s] Error: HTTP request failed with status code 403. Response content: {"error":{"message":"We are unable to serve your request","type":"permission_error"}}. Request headers: ['-H', 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', '-H', 'Cookie: sessionKey=sk-ant-sid01-xxx', '-H', 'Content-Type: application/

--- OLD

Ok I try to use WLS with Ubutu 22.04.2 LTS and login now work but on CURL mode

I think something related to CURL on my windows machine

jahwag commented 1 month ago

Closing as duplicate of #24.