-
Notifications
You must be signed in to change notification settings - Fork 157
Login
• To login you need to POST to http://www.reddit.com/api/login/USERNAME
• user=[username]
• passwd=[plaintext password]
• It always returns HTTP code 200 OK
• Need to read message content (single line JSON format) and if it contains string “WRONG_PASSWORD” then login failure.
POST /api/login/talklittle_test HTTP/1.1
Host: www.reddit.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 49
api_type=json&user=talklittle_test&passwd=hunter2
returns JSON including the cookie and modhash. (important to use api_type=json)
GOOD:
{"json": {"errors": [], “data”: {"modhash": “2y30c3rdelc449b75fc909f81d725e327ae095eda788412345”, “cookie”: “5998378,2009-09-06T19:45:42,83d5373c483422b549f9ca7b592c4ecf0dc29438”}}}
BAD:
{"json": {"errors": [["WRONG_PASSWORD", "invalid password"]]}}
me: Will the modhash returned from /api/login be valid for as long as the session cookie?
KeyserSosa: Yup. The modhash only expires when we (very seldom) update the salt used in the hash or when the user changes his or her password. For now, you can treat them as if they’ll last forever.