robin_stocks
robin_stocks copied to clipboard
Mfa Code: Please enter a valid code
Hi everyone!
I'm not sure if anyone else is facing this issue or maybe I'm doing this incorrectly but thought I'd raise it. I can use the basic login (without 2F-Authentication) just fine but I'm running into trouble when trying to log in via 2F-Authentication.
I'm using Pycharm editor, Python version 3.8 and have already installed the robin_stocks and pyotp modules.
Here's what I have done so far:
- Searched Google for the issue.
- Looked through similar or related questions already raised by the community members.
- Setup 2F-Authentication on my phone using Google Authenticator, currently enabled.
- Using the same alpha-numeric code that I manually entered in Google Authenticator.
My code is as follows:
import pyotp
import robin_stocks as r
totp = pyotp.TOTP("Same alpha-numeric code entered manually in Google Authenticator").now()
print("Current OTP:", totp)
login = r.login('[email protected]','NotSoSecurePassword', mfa_code=totp, expiresIn=120)
When I run the above code, the following exception is raised: "Please enter a valid code". Any insights would be greatly appreciated.
try opening robinhood phone app and when it asks for MFA code, run the code above so it prints out the current OTP. Then manually type that number into your phone app to see if it accepts it. Let me know what happens.
I believe what you did should work, but just so you know when i set up MFA on robinhood, i clicked "other" instead of telling it to use google authenticator. I then added the alphanumeric code to my python code to generate the MFA to complete set up. After that, is when i manually set up google authenticator with the same code.
Hey Joshua!
Yes, I tried it exactly the way you mentioned but I'm still getting the same error: Mfa code: Please enter a valid code. I had to work with Google Authenticator because for whatever reason the code generated from pyotp wasn't being accepted in the Robinhood app. Does it work in your case? Trying to understand if anyone else has encountered this issue.
Hello,
I am getting the same error. when i put in the otp in the mobile app, I am getting the error : Please enter a valid code
I couldnt get automatic MFA verification like descriibed in the recent update.. instead I made a workaround with Twilio to handle the MFA sms.