Skip to content
uencoder

Basic Auth

HTTP Basic authentication sends the username and password Base64-encoded in the Authorization header; it is simple but must be used over HTTPS.

Purpose

It provides the simplest HTTP authentication mechanism, requiring no cookies or tokens.

Mechanism

The header is Authorization: Basic base64(user:pass). The browser sends 401 plus WWW-Authenticate: Basic to trigger the login dialog. There is no expiry and no logout (closing the browser is the only way out). Base64 is not encryption, so HTTPS is mandatory to prevent credential leakage.

Use cases

  • Simple API authentication
  • Internal tool access
  • Legacy systems
  • Testing and debugging

Examples

  • Input
    user:pass
    Output
    Authorization: Basic dXNlcjpwYXNz

    Base64 encoding

Common errors

Using Basic Auth over plain HTTP (not HTTPS) leaks the password
Always pair it with HTTPS

Related terms

Related tools

References