mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Curling With Basic Auth Credentials as a unix til
This commit is contained in:
29
unix/curling-with-basic-auth-credentials.md
Normal file
29
unix/curling-with-basic-auth-credentials.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Curling With Basic Auth Credentials
|
||||
|
||||
I often use `curl` to take a quick look at the responses of particular
|
||||
endpoints. If I try to `curl` a URL that is secured with HTTP Basic
|
||||
Authentication, this is what the response looks like:
|
||||
|
||||
```bash
|
||||
$ curl staging.example.com
|
||||
HTTP Basic: Access denied.
|
||||
```
|
||||
|
||||
I can give the credentials to `curl` so that it can plug them in as it makes
|
||||
the request using the `-u` (or `--user`) flag:
|
||||
|
||||
```bash
|
||||
$ curl -u username:password staging.example.com
|
||||
<html><body>...</body></html>
|
||||
```
|
||||
|
||||
If I don't want the password showing up in my command-line history, I can
|
||||
just provide the username and `curl` will prompt me for my password:
|
||||
|
||||
```bash
|
||||
$ curl -u username staging.example.com
|
||||
Enter host password for user 'username':
|
||||
<html><body>...</body></html>
|
||||
```
|
||||
|
||||
See `man curl` for more details.
|
||||
Reference in New Issue
Block a user