Authentication for http request

When I want to use the http.request(‘https://host/tes.txt’,didGetData) is there a possibility to put in a username and a password?

I think that would have to be part of the URL. Maybe something like

1234 is a bad password, by the way. :stuck_out_tongue:

or…if you use authentication headers, you have to use the headers to post UN/PW.

check for forums, there are at least 3 threads on this subject. I know that I started one a while back :slight_smile:

Great - many thanks I’ll use the headers

I assume here you mean http authentication, ie. done by the server.

There are two common forms of http authentication - Basic, and Digest.

You can do Basic authentication like so: “https://username:password@hostname” in the URL; many (but not all) servers will pick up and use that. Note the security issue there if you use http (ie. an insecure connection).

Some servers don’t allow Basic authentication due to the security issues. You’d need to use Digest there, which involves headers. It is significantly more complex, including some ugly math - here’s a wikipedia article with details:

Before you implement Digest - I’d talk to the server owner (and try it with a browser) to ensure it actually works. :slight_smile: