nodejs robinhood api login

0 votes

I'm trying to use the Robinhood API, and I've disabled 2FA and SMS in the app, but I'm still getting an error. Does this look correct, or is Robinhood simply slow at updating when 2FA is disabled?

var credentials = {
        username: '*****',
        password: '*****'
    };
    var Robinhood = require('robinhood')(credentials, function(){
        console.log(Robinhood.auth_token());
            //      <authenticated alphanumeric token>
    })

the error

Error: token not found {"statusCode":400,"body":{"detail":"Request blocked, challenge type required.","accept_challenge_types":{"sms":"SMS"}},"headers":{"date":"Mon, 24 May 2021 22:44:07 GMT","content-type":"application/json","content-length":"93","connection":"close","server":"openresty","allow":"POST, OPTIONS","x-robinhood-api-version":"0.0.0","content-security-policy":"default-src 'none'","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","x-xss-protection":"1; mode=block","access-control-allow-origin":"https://robinhood.com","vary":"Origin","trace-uuid":"56ccb9cc-8bca-4dbd-be6f-4a6d86171354"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"api.robinhood.com","port":443,"hostname":"api.robinhood.com","hash":null,"search":null,"query":null,"pathname":"/oauth2/token/","path":"/oauth2/token/","href":"https://api.robinhood.com/oauth2/token/"},"method":"POST","headers":{"Host":"api.robinhood.com","Accept":"*/*","Accept-Encoding":"gzip, deflate","Referer":"https://robinhood.com/","Origin":"https://robinhood.com","content-type":"application/x-www-form-urlencoded","content-length":214}}}
Jun 16, 2022 in Node-js by Vaani
• 7,070 points
1,163 views

1 answer to this question.

0 votes

If you're utilising the Robinhood API, you'll need to enable 2FA. It's mentioned in the request body's detail.

"detail":"Request blocked, challenge type required.","accept_challenge_types":{"sms":"SMS"}}

Go ahead and turn it on and then you can access the api with this snippet

let Robinhood = require('robinhood')(credentials, function(data) {
    if (data && data.mfa_required) {
        var mfa_code = ""; //Notice this is blank. 
        Robinhood.set_mfa_code(mfa_code, () => {
            console.log(Robinhood.auth_token());
            Robinhood.positions((error, response, body) => {
                console.log(body);
            })
        })
    }
})

After you submit a request, you'll receive an error message, but the 2FA challenge will be delivered to the account you specified. Set the mfa code and re-run the snippet once you've got the 2FA code. You've successfully signed in after running the snippet again with a valid 2fa code. You can copy the authorization token and use it for the next 24 hours without having to go through 2FA.

answered Jun 17, 2022 by Neha
• 9,060 points

Related Questions In Node-js

0 votes
1 answer

File Download on NodeJS with use opensubtitles API

The problem is the charset output (default ...READ MORE

answered Jun 7, 2022 in Node-js by Neha
• 9,060 points
911 views
0 votes
1 answer

Can't Upload Image with Google Photos API using NodeJS

The Google Photos API requires binary-formatted material, ...READ MORE

answered Jun 10, 2022 in Node-js by Neha
• 9,060 points
1,559 views
0 votes
1 answer

How to make login with Nodejs and MongoDB?

MongoDB Login and Registration with Node js ...READ MORE

answered Jun 16, 2022 in Node-js by Neha
• 9,060 points
10,129 views
0 votes
0 answers

NodeJS HTTPS API testing with mocha and super test -"DEPTH_ZERO_SELF_SIGNED_CERT"

I need to use mocha and supertest ...READ MORE

Jun 16, 2022 in Node-js by Vaani
• 7,070 points
1,029 views
0 votes
1 answer

Cannot connect to Hive from MicroStrategy BI tool

The problem is with your hive authentication. ...READ MORE

answered May 8, 2018 in Big Data Hadoop by Shubham
• 13,490 points
1,178 views
0 votes
1 answer

Trying to call AWS API via PHP

Try using AWS SDK for PHP, Link ...READ MORE

answered Jun 6, 2018 in AWS by Cloud gunner
• 4,670 points
1,686 views
0 votes
1 answer

Problem with Swift API Gateway key authorizatiion Ask

Try to add all the headers that ...READ MORE

answered Jun 12, 2018 in AWS by Cloud gunner
• 4,670 points
764 views
+1 vote
1 answer

How to authenticate and embed Tableau Rest API using Python 2.7

Your .format() call is creating a bad ...READ MORE

answered Jul 19, 2018 in Tableau by Atul
• 10,240 points
2,813 views
0 votes
1 answer

Nodejs instagram-web can't save login session locally

There are several things you can do: Dictionary ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,060 points
977 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP