Skip to content

0auth not refreshing #300

@RobertAgee

Description

@RobertAgee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions