The -H (or –header) ‘Authorization: Basic …’ flag in a curl command sets the HTTP Authorization header using Basic Authentication.

Basic authentication is a simple HTTP authentication scheme that allows a client to provide a username and password when requesting access to a protected resource. The credentials are typically encoded in Base64 and sent in an Authorization header. While simple and easy to implement, it’s also one of the least secure authentication methods, as it transmits credentials in plain text. 

Here is an example of a GoldenGate API request to create a Distribution Path. Note that I am using the encoded representation of the username and password within the Authorization: Basic header.

echo "## Creating GoldenGate User for Distribution Path"
echo "###############################################################"
curl -X POST 'http://'$ogg_ip':'$ogg_port'/services/v2/authorizations/Operator/oggnet' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H 'Authorization: Basic b2dnYWRtaW46V2VsY29tZTEyMyMj' \
-d '{
"credential":"'$GLOBAL_PASS'",
"info":"Distribution Path User"
}'

Breakdown:

  • -H means “add an HTTP header”.
  • ‘Authorization: Basic …’ is the actual header being added.
  • Basic indicates the authentication scheme.
  • The part after Basic is a Base64-encoded string of the format: username:password

Example:

If your username is admin and password is Welcome123##, the command:

$echo -n "oggadmin:Welcome123##" | base64

outputs something like:

b2dnYWRtaW46V2VsY29tZTEyMyMj

So your curl command becomes:

curl -H "Authorization: Basic b2dnYWRtaW46V2VsY29tZTEyMyMj" https://localhost:9090<endpoint>

Encrypting the entire request with HTTPS is the best practice for securing your personal information, including headers (like Authorization) and payload.


Note:

Instead of manually encoding credentials, curl provides a more straightforward method with username and password:

curl -u admin:mypassword https://localhost:9090/<endpoint>

You can test and experiment with Encode and Decode Base64 here: https://passwords-generator.org/base64-encode