jmfernandes / robin_stocks

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at
http://www.robin-stocks.com
MIT License
1.73k stars 467 forks source link

Too many login requests #342

Open ravi-bharadwaj opened 2 years ago

ravi-bharadwaj commented 2 years ago

Its more than a week now since I am able to login via api.

I get the following error

"Your login couldn't be completed at this time - we've received too many login attempts from your network. Switching to a different internet connection may help you log in to your Robinhood account."

Any idea on how long does api.robinhood.com hold a block for?

I can login to robinhood without any issues but not via the API from same computer.

Nllii commented 2 years ago
  1. Duration of lock was 12 hours on my IP.

  2. Use a VPN if you need to keep making requests

  3. https://www.arkoselabs.com

You can update and fix authentication.py

import requests
import pprint

def al_token():
    al_pk = ""
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36',
        'Referer': 'https://robinhood.com/login',
        'Origin': 'https://robinhood.com/',
        'Content-Type': 'application/x-www-form-urlencoded',
    }
    data = 'bda=e30=&public_key='+al_pk+'&site=https://robinhood.com/login&userbrowser=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36&simulate_rate_limit=0&simulated=0&language=en&rnd=0.21477650373695933'
    response = requests.post('https://robinhood-api.arkoselabs.com/fc/gt2/public_key/', headers=headers, data=data)
    for key, value in response.json().items():
        if key == 'token':
            token = value.split('|')[0]
        return token

json_data = {
    'device_token': '',
    'al_pk': ',
    'password': ',
    'username': '',
    'scope': 'internal',
    'client_id': 'c82SH0WZOsabOXGP2sxqcj34FxkvfnWRZBKlBjFS',
    'skip_prompt': True,
    'grant_type': 'password',
    'al_token': 'e30='+str(al_token()),
}

response = requests.post('https://api.robinhood.com/oauth2/token/', headers=headers, json=json_data)
return response
{'mfa_required': True, 'mfa_type': 'app'}

once you get the response, just pass it on to line.

https://github.com/jmfernandes/robin_stocks/blob/8359444cb75e050662520aebef8a9c1bdb26bf1c/robin_stocks/robinhood/authentication.py#L153

ravi-bharadwaj commented 2 years ago
  1. Duration of lock was 12 hours on my IP.
  2. Use a VPN if you need to keep making requests
  3. https://www.arkoselabs.com

You can update and fix authentication.py

import requests
import pprint

def al_token():
    al_pk = ""
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36',
        'Referer': 'https://robinhood.com/login',
        'Origin': 'https://robinhood.com/',
        'Content-Type': 'application/x-www-form-urlencoded',
    }
    data = 'bda=e30=&public_key='+al_pk+'&site=https://robinhood.com/login&userbrowser=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36&simulate_rate_limit=0&simulated=0&language=en&rnd=0.21477650373695933'
    response = requests.post('https://robinhood-api.arkoselabs.com/fc/gt2/public_key/', headers=headers, data=data)
    for key, value in response.json().items():
        if key == 'token':
            token = value.split('|')[0]
        return token

json_data = {
    'device_token': '',
    'al_pk': ',
    'password': ',
    'username': '',
    'scope': 'internal',
    'client_id': 'c82SH0WZOsabOXGP2sxqcj34FxkvfnWRZBKlBjFS',
    'skip_prompt': True,
    'grant_type': 'password',
    'al_token': 'e30='+str(al_token()),
}

response = requests.post('https://api.robinhood.com/oauth2/token/', headers=headers, json=json_data)
return response
{'mfa_required': True, 'mfa_type': 'app'}

once you get the response, just pass it on to line.

https://github.com/jmfernandes/robin_stocks/blob/8359444cb75e050662520aebef8a9c1bdb26bf1c/robin_stocks/robinhood/authentication.py#L153

For some reason its almost 2 weeks now since the issue started and its still not resolved yet.

I tried to use your fix, but its an error saying invalid-grant. Have been using vpn but its slow.