jgillick / LendingClubAutoInvestor

A simple command line tool that will automatically invest all cash that becomes available
MIT License
47 stars 21 forks source link

Cannot authenticate #3

Closed ilyakatz closed 11 years ago

ilyakatz commented 11 years ago

When I run the script, I get stuck on authentication

~/ws/LendingClubAutoInvestor (master)$ ./bin/lcinvestor 

///--------------------------- $$$ ---------------------------\\\
|    Welcome to the unofficial Lending Club investment tool     |
 ---------------------------------------------------------------- 

To start, we need to log you into Lending Club (your password will never be saved)

LendingClub email: ilyakatz@gmail.com
Password: 

Authenticating...
ERROR: 2013-06-11 22:18 - Authentication returned 200. Cookies: []

Could not authenticate, please try again

Any ideas how to debug this? Thanks

ilyakatz commented 11 years ago

Using Mac OS X if it makes a difference

TobyDai commented 11 years ago

I'm getting the same error as well.

jgillick commented 11 years ago

I'm looking into this.

jgillick commented 11 years ago

Silly question, but you're sure that you're entering a valid password, right?

TobyDai commented 11 years ago

I know I did. Here s my error message.

ERROR: 2013-06-11 22:18 - Authentication returned 200. Cookies: ['JSESSIONID-lcui-stage']

ilyakatz commented 11 years ago

same here, checked and rechecked that the password is correct

jgillick commented 11 years ago

I just pushed some code to master that should handle login a little better and output more useful debugging information. Download the latest from github (not pip), install it and run it in the foreground with the verbose flag:

lcinvestor -v

Let me know if this works and post the output of authentication here. If it doesn't work, also pos the output from running pip list.

ilyakatz commented 11 years ago

Just tried again and same thing

~/ws/LendingClubAutoInvestor (master)$ bin/lcinvestor  -v
DEBUG: 2013-06-12 14:21 #207 - No saved investment settings file to load

///--------------------------- $$$ ---------------------------\\\
|    Welcome to the unofficial Lending Club investment tool     |
 ---------------------------------------------------------------- 

VERBOSE OUTPUT IS ON

To start, we need to log you into Lending Club (your password will never be saved)

LendingClub email: ilyakatz@gmail.com
Password: 

Authenticating...
DEBUG: 2013-06-12 14:21 #108 - POSTING https://www.lendingclub.com/account/login.action
ERROR: 2013-06-12 14:21 #675 - Authentication returned 200. Cookies: []

Could not authenticate, please try again
~/ws/LendingClubAutoInvestor (master)$ pip list
argparse (1.2.1)
beautifulsoup4 (4.2.1)
distribute (0.6.36)
git-remote-helpers (0.1.0)
html5lib (1.0b1)
lcinvestor (1.0.7)
lockfile (0.9.1)
pybars (0.0.4)
PyMeta (0.5.0)
python-daemon (1.6)
PyYAML (3.10)
requests (1.2.3)
six (1.3.0)
wsgiref (0.1.2)
yamltools (0.1)
jgillick commented 11 years ago

It looks like your code didn't update. It should now display some extra information when the authentication fails. For example a 'Login error message' (line 685) which is the login error that is returned from the LendingClub login form.

Be sure you're using code from this commit or later: https://github.com/jgillick/LendingClubAutoInvestor/commit/4d8417265396be2679a2c6f2a53da92eeafd8378#LendingClubInvestor

ilyakatz commented 11 years ago

ah sorry, forgot to put "./" before bin/lcinvestor

well, it seems to have logged me in now! i did have to install pip install pause

now getting a different error. Maybe I can play with this later - I don't code python so it's an extra challenge :)

ERROR: 2013-06-12 15:00 #514 - Could not get the cash balance on the account: Expecting property name enclosed in double quotes: line 1 column 39 (char 38)
JSON: {"result": "error","silent": "silent",}
You have $-1 in your account, free to invest
jgillick commented 11 years ago

That's really interesting. It appears that you're still not being authenticated by LendingClub. The code gets your cash balance by accessing this URL: https://www.lendingclub.com/browse/cashBalanceAj.action

You'll notice that when you're logged in, it should output your cash balance in a JSON text format. If you're not logged in, it'll return error text.

This is really strange. What was the output before that error message? There should be a DEBUG line that contains the text "Redirected to".

TobyDai commented 11 years ago

I'm now getting the identical error as well

TobyDai commented 11 years ago

Redirected to http://www.lendingclub.com/account/summary.action Success!

jgillick commented 11 years ago

What about the cookies line?

TobyDai commented 11 years ago

I'm not getting any message regarding cookies.

jgillick commented 11 years ago

Eureka! It seems to be something to do with the Python requests module. I was using version 1.2.0 and when I upgrade to 1.2.3, I get the same error you're getting. This is great news! Now I can fix it directly.

While I fix this, and out of pure curiosity, how'd you both hear about this tool? :)

TobyDai commented 11 years ago

I found this project while googling Lending Club API related stuffs, and this is super awesome!

ilyakatz commented 11 years ago

@jgillick thanks for your help with this! I got here same way as @tobydai, I was ready to start my own project and then found this :)

jgillick commented 11 years ago

Good news, I'm pretty sure I found and fixed the problem. After upgrading to requests 1.2.3 (I was formerly on 1.2.0) I started seeing the same error. Somewhere between 1.2.0 and 1.2.3, the module stopped forwarding the cookies after an HTTP redirect. In any case, it's working for me now.

Also, tobydai, I've updated the code to only include the daemon module for systems that support it.

TobyDai commented 11 years ago

Works beautifully now!!! Thanks so much @jgillick!! Now, is it possible to add an option to return a list of loans matching the criteria before committing to fund?

jgillick commented 11 years ago

That's a good idea. Currently the tool is primarily for automated passive investing, but I'm planning to break an API out soon and could potentially add that. Then I suppose the tool would turn into some sort of a LendingClub console or something. Feel free to fork the code if you would like to take a try at it.

jgillick commented 11 years ago

Fixed with commit https://github.com/jgillick/LendingClubAutoInvestor/commit/146a4b5295d49ee7b9639c541ea160fe5364a170

ilyakatz commented 11 years ago

@jgillick awesome! thanks a bunch. i was too impatient today and invest all the cash that I had, so I will try it out in the next couple of days. Really looking forward to using it more

jgillick commented 11 years ago

FYI: I've just added a feature request to my list to extract the LendingClub API out of the auto investor into it's own standalone Python module. This will make it easier for other developers to interface with LendingClub in their own projects (or to enhance this one).