POST for password protected url?

I am working on a project that requires me to POST some data to a URL that requires a username and password to access. How to create a url so that it automatically logs in?

$.ajax({ url: "https://xxxxxxx", type: "POST", data: "___PUT_BODY___="+file+"&file="+time, }) 
+7
jquery user-interface post php username
source share
3 answers

If the page uses "Basic" HTTP authentication (the view in which the browser opens a small dialog box asking for a username and password), you can simply do:

 https://username:password@www.example.com/ 

If the site has a login form embedded in the page somewhere, then login information for the URL is not specified. You will need to simulate submitting this form (by creating a similar AJAX request specifically for logging in).

+6
source share

Read the funny guide

In addition, do not create the query string as it appears in the URI panel, make it an object. Also at the end of this statement is a semicolon.

 $.ajax({ url: "https://example.com", type: "POST", data: { "___PUT_BODY___=" : file, "&file=" : time }, password : "theP4s$w0rD!", username : "Bob big bad world of HTTP Auth" }); 
+2
source share

If the page you are sending the message to is publicly available, if the username / password should remain closed, you should review your username / password on the page.

You can publish on the local page of your server, which, in turn, can send data, for example, using curl to the receiving server.

Also, using curl, you can perform any authentication you need.

0
source share

All Articles