pyrh: Login error seems to be back.

I installed Python 3.8, got all the necessary libraries, and got a fresh install of this repository. Then I try to run example.py and I get:

requests.exception.hTTPError: 400 Client Error: Bad request for url: https://api.robinhood.com/oauth2/token/

During handling of the above exception another exception occurred:

raise RH_exception.LoginFailed()

I saw another user say that (months ago) Robinhood updated their payload requirements but I have seem to met them?

payload = {
  'client_id': MYCLIENTID,
  'device_token': MYDEVICETOKEN,
  'expires_in': 86400,
  'grant_type': 'password',
  'scope': 'internal',
  'password': MYPASSWORD,
  'username': MYUSERNAME
}

Still get a login failed… Used to work!!!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Same problem here

It appears that the login requires device_token. I tried to push my changes by creating a PR but received an authorization error.

In order for you to make it work, you could use uuid library to generate a device token in Robinhood.py file.


class Robinhood:

  def login(self,
                username,
                password,
                mfa_code=None):

    devicetoken = uuid.uuid1()

    self.username = username
            payload = {
              'password': password,
              'username': self.username,
              'grant_type': 'password',
              'client_id': self.client_id,
              'device_token': devicetoken
            }

@zacharytyhacz @diogobotelho have you tried the project recently? Login works

@peweetheman @tipu I think I know why it’s not working. with uuid.uuid1(), it is actually sending an UUID object and not an actual UUID hex string. try devicetoken = uuid.uuid1().hex and it should work.

I made those changes, still getting the error