question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Login Errors with 2FA (email code)

See original GitHub issue

Checklist

  • [ x] I am on the latest pyrh version.
  • [ x] I have searched the issues of this repo and believe that this is not a duplicate.

Description

Getting an error when trying to log in following instructions on quickstart, prompts for a 2FA email code and I enter the SMS code which fails to work

Steps/Code to Reproduce

import config

robinhood = Robinhood()

robinhood.login(username= config.username, password= config.password)

quote = robinhood.quote_data("TWTR")

print(quote)

Results

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyrh/robinhood.py", line 215, in login
    res2.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.robinhood.com/challenge//respond/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "trade.py", line 6, in <module>
    robinhood.login(username= config.username, password= config.password)
  File "/usr/local/lib/python3.7/site-packages/pyrh/robinhood.py", line 228, in login
    raise RH_exception.LoginFailed()
pyrh.exceptions.LoginFailed

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
yanniskatsaroscommented, Feb 17, 2021

Ok, I think I figured out the issue! 🎉

In the constructor for Robinhood.login() there is a keyword argument challenge_type. The default is email. Change this to whatever 2FA format you prefer. I’m not sure what all the available options are (not really documented anywhere) but I changed mine to sms and it worked.

Here’s an example below.

import os
from pyrh import Robinhood

USERNAME = os.getenv('ROBINHOOD_USERNAME')
PASSWORD = os.getenv('ROBINHOOD_PASSWORD')

rh = Robinhood()
rh.login(username=USERNAME, password=PASSWORD, challenge_type='sms')

You should receive your 2FA code via SMS - enter it and it should return True.

Note I don’t have 2FA turned on in my Robinhood app settings.

Hope this helps!

2reactions
Jamonekcommented, Apr 17, 2022

Sorry everyone for leaving y’all hanging! I’ve been busy lately with other projects. I’ll do more research into this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem Solving Login Issues with Two-Factor Authentication
I just logged in to Console site, but now my authentication code isn't working for Author site. General two-factor authentication login issues.
Read more >
Fix common issues with 2-Step Verification - Google Support
To enter a code sent to your email address or phone number. This code helps make sure you can access that email address...
Read more >
Common problems with two-step verification for a work or ...
If you've mistakenly made many sign-in attempts, wait until you can try again, or use a different MFA method for sign-in. If you...
Read more >
What should I do if I've activated 2FA, but lost access to the ...
This is a confirmation code generated by an authentication app, also called an OTP app, on your smartphone or other device. To ensure...
Read more >
"Invalid Code. Try Again." error message when trying to login ...
Two-factor authentication (2FA) is a method of securely verifying your identity using two pieces of evidence instead of one.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found