Robinhood Authentication through MFA as described here https://robin-stocks.readthedocs.io/en/latest/quickstart.html#with-mfa-entered-programmatically-from-time-based-one-time-password-totp was working until Dec 17. I have tried multiple times but unsuccessful. Is anyone experiencing a similar issue?
The error message is not very helpful.
Traceback (most recent call last):
File "rhs.py", line 962, in f2
rbh_ = rbh.authentication.login (username="....", password="....", mfa_code=totp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mycomputer/anaconda3/lib/python3.12/site-packages/robin_stocks/robinhood/authentication.py", line 198, in login
raise Exception(data['detail'])
~~~~^^^^^^^^^^
KeyError: 'detail'
I tried to print what data
contains and obtained the following. (Note: data = request_post(url, payload)
within the robin_stocks/robinhood/authentication.py
).
{'verification_workflow': {'id': '***5d74a-****-****-9721-cb00a6d69***', 'workflow_status': 'workflow_status_internal_pending'}}
Could it be that the 'client_id': 'c82SH0WZOsabOXGP2sxqcj34FxkvfnWRZBKlBjFS',
used in the payload
used for authentication (within the robin_stocks/robinhood/authentication.py
file) is no longer allowed by robinhood?
url = login_url()
payload = {
'client_id': 'c82SH0WZOsabOXGP2sxqcj34FxkvfnWRZBKlBjFS',
'expires_in': expiresIn,
'grant_type': 'password',
'password': password,
'scope': scope,
'username': username,
'challenge_type': challenge_type,
'device_token': device_token
}
Any help will be greatly appreciated.
Mitch Zink has proposed a solution here that works for me --> https://github.com/jmfernandes/robin_stocks/issues/521#issuecomment-2551281316
I summarize the solution as follows:
It appears there was a recent update to the Robin-Stocks library that requires manually pulling the repository instead of using the package, as the package itself has not been updated yet. To ensure you have the latest version, please follow these steps:
Check for existing Robin-Stocks submodule. If the submodule exists, pull the latest changes. Else if the submodule does not exist, clone it. Then install Robin-Stocks in editable mode.
# Adding or updating Robin-Stocks as a submodule.
if [ -d "robin_stocks" ]; then
echo "Robin-Stocks submodule already exists. Pulling latest changes."
git -C robin_stocks pull origin master
else
echo "Cloning Robin-Stocks as a submodule."
git submodule add https://github.com/jmfernandes/robin_stocks.git robin_stocks
git submodule update --init --recursive
fi
# Installing Robin-Stocks in editable mode.
pip install -e robin_stocks
This will ensure that you have the latest version of Robin-Stocks, preventing the login issues.
After that, try logging in using the MFA as described here https://robin-stocks.readthedocs.io/en/latest/quickstart.html#with-mfa-entered-programmatically-from-time-based-one-time-password-totp
import pyotp
import robin_stocks.robinhood as r
totp = pyotp.TOTP("My2factorAppHere").now()
login = r.login('joshsmith@email.com','password', mfa_code=totp)