How to make node.js authentication from a third party source?

Good afternoon.
There is a website written in asp code which I don't have access to. Programmer support online promises to write an external service to send the data. But it lasts for a long time, and the data for conducting the analytical work needed now.
The problem is that there first needs to enter a username and password. And the data I want to collect an automatic.
The authentication in the course of the underlying is used because I don't see that the browser in the headers kept this info after a successful call. And attempts to drop all my failed. So I decided to use the module request. And to send the first post for authorization and then saved the cookie to use for get requests. And here the problems started.
For authentication, use the page to login which then is sent Form Data with username and password.
Through various eksperimentov begat this code:

var postData={
 Login: 'login', PWD: 'pasword'
 uri:"<a href="http://mysite/Login.asp">http://mysite/Login.asp</a>",
 headers:{'content-type': 'application/x-www-form-urlencoded'},

Eventually get started the following result:
<title>Object moved</title>

<h1>Object Moved</h1>This object may be found <a href="/Main.asp">here</a>.

Kind of like we came in and we were transported to the main page and because of the limitations of the module, it just failed to get it, but all my parcels get led again to the page Login.asp. I already cook my generates and send it in the post and then get.

Hence, the question arises about the reality of my volition. How to do all this, because I feel instinctively that it is possible as it's easier to do and not to transfer login and the password explicitly.

October 3rd 19 at 02:00
1 answer
October 3rd 19 at 02:02

1. Activate cookies: var request = request.defaults({jar: true})
2. Also, try to add parameter: followAllRedirects: true
3. Why you can not continue in the callback from the post add request.get('http://mysite/Main.asp', function(err,res,body){ console.log(body); });

1. I did forgot in the code to insert 2. I don't need it. I later had requests to send. 3. Now repeated, and does work, although yesterday just so did the guys, then really digging in the code history I realized that a new request object created when sending the get. Thank you for your time on me) - Denis commented on October 3rd 19 at 02:05

Find more questions by tags Node.js