curl plus basic http auth? quick fix

You need to test the response on your basic http auth’d dev server.  You want to pass it in the header.  You’re on a real computer…

1) Encode your credentials.  Notice passing -n to echo so we don’t get a trailing newline.

  • $ echo  -n ‘<username>:<password>’ | openssl enc -base64
    • feel free to verify $ echo -n ‘foo:bar’ | openssl enc -base64 | openssl enc -base64 -d

2) Send request

  • $ curl <url> -h “Authorization: Basic <encoded_cred_string>”
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s