Basic Authentication in JMeter

While using JMeter, basic authentication is a common issue that testers face. The way to get around this is to do base64 encode of '#{username}:#{password}' and pass it in as the authentication header. Let us discuss this in details.

Let's see the step-by-step implementation:

Step 1: HTTP Request sampler
Step 2: HTTP header manager
Step 3: Listeners

Step 1:  HTTP Request Sampler

Let's first create a HTTP Request sampler in our test plan.

Right-click on Thread Group → Add → Sampler → HTTP Request.

The next step is

  1. Enter the Name of the HTTP Request,
  2. Protocol
  3. Server Name or IP

An example is given below:

Step 2: HTTP Header Manager

Next step is to add HTTP header manager in our test plan.

You can find the HTTP header manager in Thread group → Add → Config Element → HTTP Header manager.

After adding “HTTP Header Manager” as above, we will need login credentials strings in base64 encoded format to continue. We can use online tools ( to encode colon-separated username and password ( Example: username: password) and paste the base64 encoded string in the authorization header value in the Header Manager as shown in the following screenshot.

Add the Header Name and Value pair by clicking on the “Add” button at the bottom of HTTP Header Manager.

Example :

Name : authorization
Value : basic{dXNlcm5hbWUgOiBwcmF0aWsxMjM=}

Save it by clicking on the save button at the top left menu bar.

Step 3: Listener

Finally, let's add a LISTENER to see a basic authorization in action.

  1. Go to Thread group → add → Listeners →View results in Table.

After following the above steps, Click RUN from the top bar.

Once you run the script, Go to the "View results in Table" and you will see the results like

Congrats!!! If the status is a Green Icon, you have successfully tested the Basic Authentication protected web route.

Pratik Thakare

Pratik Thakare

QA Test Engineer at