Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Fix 400 error on mfa authentication #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

k3an3
Copy link
Contributor

@k3an3 k3an3 commented May 11, 2019

The web API uses device_token as one of the fields during authentication. Looking at the issues for this and other similar API clients, people have been generating these randomly but it can also be done by the standard uuid library.

Without this change, I get this error calling Client.authenticate():
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.robinhood.com/oauth2/token/

Second, the API also takes a nonzero parameter when fetching all options positions. Thought it was nice to include this since you don't get as much garbage data this way. Could even make this the default option if so inclined.

@westonplatter
Copy link
Owner

Thanks @k3an3 for the PR.

What kind of garbage data is excluded?

@k3an3
Copy link
Contributor Author

k3an3 commented May 12, 2019

If you don't include nonzero=True, the positions returned includes (all?) historic options positions where the quantity == 0. So if I run it the default way, I get my current open positions (which is only a few entries), and then basically every single other position I've ever had. It seems slower to pull all of this data, and I don't think it is necessary unless you are specifically trying to go back and look at all of your historic options. This fix just saves you from filtering by positions with quantity != 0

@wardnath
Copy link

wardnath commented Jul 18, 2019

I've found that I need to include X-ROBINHOOD-CHALLENGE-RESPONSE-ID to the headers to resolve the 400 issue.

see: robinhood-unofficial/pyrh#176 (comment)

@westonplatter
Copy link
Owner

@k3an3 @wardnath I moved authentication operations into a new library, fast_arrow_auth. I used your code changes to help figure out how handle the device token there (THANKS!!). What I'm thinking is make update this PR to only contain the nonzero logic.

@westonplatter
Copy link
Owner

@k3an3 I pull in your option position changes into #97 and resolved the merge conflicts there. I'll wait a couple of days in case you had thoughts or feedback on how I adjusted the code changes.

Thanks a ton for your help on removing garbage data from the options position code.

@westonplatter
Copy link
Owner

@k3an3 I went ahead and merged #97 with your option position API changes.

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

Successfully merging this pull request may close these issues.

3 participants