claude-api-py icon indicating copy to clipboard operation
claude-api-py copied to clipboard

HTTP Error 403: Forbidden

Open codemurt opened this issue 11 months ago • 6 comments

I'm trying to run this code:

from claude import claude_client
from claude import claude_wrapper
SESSION_KEY = <MY_SESSION_KEY>
client = claude_client.ClaudeClient(SESSION_KEY)
organizations = client.get_organizations()
organizations

but I get this:

WARNING:root:Failed response object: Response(ok=False, data=b'', status_code=None, error='HTTP Error 403: Forbidden')
None

I don't really understand what the problem is.

codemurt avatar Mar 16 '24 16:03 codemurt

Could you dump the logs, try a different session key, or try a different account?

AshwinPathi avatar Mar 17 '24 00:03 AshwinPathi

I have the same problem. [17-Mar-24 18:10:48:root:WARNING][claude_client.py:304 - get_organizations() ] Failed response object: Response(ok=False, data=b'', status_code=None, error='HTTP Error 403: Forbidden') None

sakurakoujirabbit avatar Mar 17 '24 10:03 sakurakoujirabbit

same case here

gerkim62 avatar Mar 17 '24 14:03 gerkim62

same error that happened since last Friday

jensen1207 avatar Mar 18 '24 05:03 jensen1207

same, probably some additional headers or security was added recently.

AshwinPathi avatar Mar 19 '24 06:03 AshwinPathi

@jensen1207 @gerkim62 @sakurakoujirabbit @codemurt

The problem is anthropic uses cloudflare cookies to prevent bots. These cookies refresh periodically, so this probably isn't a permanent solution. The "real" best way to solve this would be to completely mock the browser or find some way to bypass cloudflare cookies. The former is too heavyweight and the latter might be difficult.

Since this is also kind of against their TOS, I don't think I can comment more.

AshwinPathi avatar Mar 19 '24 07:03 AshwinPathi