How to Use curl with Username and Password for Secure API Authentication?

9 Replies, 1986 Views

If you’re using curl with username and password frequently, consider writing a small script to handle the auth part. That way, you can keep your credentials in one place and call the script whenever needed.

Example:
```bash
#!/bin/bash
curl -u $1:$2 https://api.example.com
```
Save it as `api_call.sh` and run it like `./api_call.sh username password`.

Messages In This Thread



Users browsing this thread: 1 Guest(s)