aurbano / robinhood-node

:chart_with_upwards_trend: NodeJS client for Robinhood Trading :fire:
https://aurbano.github.io/robinhood-node
MIT License
694 stars 184 forks source link

`instruments` does not work with token #94

Closed prmichaelsen closed 5 years ago

prmichaelsen commented 5 years ago

// Below is an issue template, feel free to modify it

Code being executed: Where api is an authenticated robinhood session:

            const instrumentsBody = await new Promise<any>(async (resolve, reject) => {
                api.instruments(symbol, (err, res, body) => {
                    console.log('body', body);
                    if (err)
                        reject(); // TODO better handling
                    if (body)
                        resolve(body);
                });
            });

Expected result

An instruments response.

Actual behaviour

{ details: 'Invalid bearer token' }

// Either the error you received, or the JSON that was returned

Reproducing

Try to use a token to get a response from instruments.

// Please provide a bit of context for the code snippet, were you authenticated? Yes

Note

Something interesting I've noticed is that instruments does not seem to require auth.

curl -v https://api.robinhood.com/instruments/?symbol=MSFT

The above works fine, as does the below

            const instrumentsBody = await (await fetch(
                ['https://api.robinhood.com/instruments/?symbol=', symbol.toUpperCase()].join('')
            )).json();

As a result, I'm not sure if the instruments function requires an update. Please let me know what you think.

prmichaelsen commented 5 years ago

The more I work with this, the more I suspect it has something to do with how I am authenticating. It seems to be the case that I have in fact acquired an invalid bearer token somehow.

prmichaelsen commented 5 years ago

Yes, upon further investigation, the case is that my token is in fact invalid. I am closing this issue.