Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can No Longer Login To Robinhood via robin-stocks API #513

Open
Two20Two21 opened this issue Dec 7, 2024 · 4 comments
Open

Can No Longer Login To Robinhood via robin-stocks API #513

Two20Two21 opened this issue Dec 7, 2024 · 4 comments

Comments

@Two20Two21
Copy link

Two20Two21 commented Dec 7, 2024

Problem Statement:

I have been running robin-stocks API to access Robinhood for a few months. I've had no issues until a few days ago. Now, I cannot login.

Previously, Robinhood has asked me to verify it's me and then I have to input an MFA code. Now, it still asks me to verify it's me but before asking me to input the MFA code, it stops due to an unhandled exception. Looking at the API code, it appears the code expects an 'access_token' to be returned. When there isn't one, it throws the exception. I get back code 403.

I have not changed anything I am aware of. I've even gone back to a compiled version that's been working since 11/21/24 and it now does not work either. I've tried inputting a new Authenticator App code. My email and password are correct. The problem is occurring on two different computers, both previously working fine.

I'm stumped. Please help.

My Code:

import robin_stocks.robinhood
import pyotp
from datetime import *

now = datetime.now()
totp = pyotp.TOTP("KACUJH6EKZZCVZ6K").now()
print("TOTP: " + str(totp))
login = robin_stocks.robinhood.login(my_user_name, my_password, store_session=True)

Console Error:

Connected to pydev debugger (build 242.23339.19)
TOTP: 699780
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2024.2.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\JetBrains\PyCharm 2024.2.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\kbens\OneDrive\Earnie TradeBot\Code\Earnie\StockTest.py", line 13, in
login = robin_stocks.robinhood.login(my_user_name, my_password, store_session=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kbens\AppData\Local\Programs\Python\Python312\Lib\site-packages\robin_stocks\robinhood\authentication.py", line 197, in login
raise Exception(data['detail'])
~~~~^^^^^^^^^^
KeyError: 'detail'

Process finished with exit code 1

API Code: last line with "raise Exception" is where the error occurs, no 'detail' in data, there was no access_token which seems to be the fundamental problem.

    if 'access_token' in data:
        token = '{0} {1}'.format(data['token_type'], data['access_token'])
        update_session('Authorization', token)
        set_login_state(True)
        data['detail'] = "logged in with brand new authentication code."
        if store_session:
            with open(pickle_path, 'wb') as f:
                pickle.dump({'token_type': data['token_type'],
                             'access_token': data['access_token'],
                             'refresh_token': data['refresh_token'],
                             'device_token': payload['device_token']}, f)
    else:
        raise Exception(data['detail'])    <<<<<<<<<<<<<<<<<<< Exception is here
@Christopher-C-Robinson
Copy link

Try using #510. This worked for me.

@Two20Two21
Copy link
Author

Two20Two21 commented Dec 8, 2024 via email

@Christopher-C-Robinson
Copy link

if that doesn't work. Seems this works for those that #510 doesn't work for:
#511 (comment)

@Two20Two21
Copy link
Author

Two20Two21 commented Dec 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants