How to login using Reddit's API? How to login using Reddit's API? curl curl

How to login using Reddit's API?


The following is a proper example of how to use curl to login to reddit:

curl -duser=USERNAME -dpasswd=PASSWORD -dapi_type=json https://ssl.reddit.com/api/login

By passing api_type=json you get meaningful json output rather than reddit-specific jquery based output.

{"json": {"errors": [],          "data": {"modhash": "<REMOVED>",                   "cookie": "<REMOVED>"}         }}

Note that reddit also properly uses the set-cookie header so that a proper http client / library will take advantage of the session for subsequent requests.

Your example did not work because you were not properly sending the form parameters. The example that you thought might have worked, in-fact did not. You were receiving a rate-limit response for failing to login too many times.