HttpRequest with signing in

331 views
Skip to first unread message

bill t

unread,
Jan 25, 2018, 11:44:02 PM1/25/18
to DroidScript
Dear DS team,
I want to use HttpRequest to get web as text but the web require sign in. So, how to send HttpRequest with sign-in information or how to keep sign-in then HttpRequest ?
Thank you!

Nino Porcino

unread,
Jan 26, 2018, 7:31:53 AM1/26/18
to DroidScript
is it standard HTTP authentication? or it's just a website that requires you to register and then login via filling a form?

(how to tell: the former prompts you very basic username/password window, the latter is a form on the webpage)

If it's standard HTTP auth, then look here:


If it's form-based authenticantion, then it depends on the specific website. Mostly you do a POST request with username and password encoded in a form (

application/x-www-form-urlencoded), and wait for the response which normally sends you a cookie to be used in all successive HTTP requests.




bill t

unread,
Jan 27, 2018, 2:14:03 AM1/27/18
to DroidScript
Thank nino,
I need get a webpage which display after submit login page. I use HTTPRequest or XMLHttpRequest in DS to get that. I want to request login once for many times HttpRequest.
So, can you give me example codes about 2 case you said ?
Thank you very much!

Nino Porcino

unread,
Jan 27, 2018, 3:55:53 AM1/27/18
to DroidScript
It is difficult to say without knowing the specific web site. 

Speaking generally you do this:

1) send HTTP request to login page with username and password encoded in the form

2) wait for the response, and see if there are cookies set within, save them apart

3) send HTTP request to your "datapage" and include the cookie in the request

In other words, HTTP connection is stateless, so the server sends a cookie to the client and expects to find that cookie in all successive requests.

My advice is to use the network inspector in Chrome (F12 key -> Network) and see how exactly how HTPP requests and responses are formed. E.g. hit F12, click "networks" then login to your site and see what happens.
Reply all
Reply to author
Forward
0 new messages