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

0auth not refreshing #300

Closed
RobertAgee opened this issue Nov 30, 2022 · 2 comments
Closed

0auth not refreshing #300

RobertAgee opened this issue Nov 30, 2022 · 2 comments
Labels

Comments

@RobertAgee
Copy link
Contributor

I'm encountering an issue with 0auth not refreshing on subsequent initializations.

Code being executed:

from pyrh import Robinhood, load_session, dump_session
from pyrh.models import SessionManager

try:
    load_session("./login.json")
    print("Loading previous session")
except:
    rh = Robinhood(username="xxx@xxx.com", password="12345")
finally:
    sm = SessionManager(username="xxx@xxx.com", password="12345")
    sm.login(force_refresh=True)
    print("Updating session")
    dump_session(sm, "./login.json")
    print("Saving updated session")
    print(sm)

login.json output on the first initialization with mfa

{
    "expires_at": "2022-12-07T11:14:23.234234+00:00",
    "challenge_type": "sms",
    "oauth": {
        "access_token": "ALKAJW3LJL3ASDLMKKLASsaldkfjalsdfai939afalj339a9dujs",
        "refresh_token": "33KL32AMCADA9IDSA9",
        "expires_in": 813842
    },
    "password": "12345",
    "device_token": "a3adsj345-e9w3-323a-a4a3-32lkj32ha8",
    "username": "xxx@xxx.com"
}

login.json output on next execution

{
    "username": "xxx@xxx.com",
    "expires_at": "1970-01-01T00:00:00+00:00",
    "challenge_type": "sms",
    "oauth": {},
    "password": "12345",
    "device_token": "dslak3lj2342-e234-14ls-3k39-jlf9sd93wlk39"
}

Where I'm at and what I'm attempting

After initialization with mfa, there is a 0auth token in the saved credentials, and the next execution is able to login fine and bypass unnecessary mfa. However, the login() function appears to not be refreshing the 0auth, even when the force_refresh is set to True. Thus on the third execution, it defaults back to mfa.

I'm looking at the pyrh methods to see where something might be amiss, but as of yet I haven't found anything obvious. Apologies if I'm merely looking over something.

@RobertAgee
Copy link
Contributor Author

I've resolved this issue by implementing OTP verification in pyrh itself and made a pull request.

@adithyabsk
Copy link
Member

This will land when I cut the next release of pyrh, until then feel free to install from master

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

No branches or pull requests

2 participants