Azure Load Testing Series - Accessing bearer token in Jmeter between different thread groups using BeanShell Assertion

Series - azureloadtesting

Hey folks!, In this blog we will see how to pass bearer token dynamically between two different thread groups using bean shell assertions. We will continue with the same Mock API that we used in our previous blog

In order to cover the scenarios, I have used a mock API that exposes token endpoint and a dummy GET endpoint.

  • Now we can move our existing “Get access token” HTTP request to newly created thread group

  • Now we can set a property similar to global variables that can be referenced in other thread groups

  • In the script window type below command
props.put("access_token", vars.get("auth_token"));

  • Now we can add a pre processor in the other thread group where we wanted to consume the auth_token by right clicking on ThreadGroup->Add->PreProcessors->BeanShell PreProcessor

  • In the script window type below command
String auth_token = props.get("access_token");
vars.put("auth_token", auth_token);

  • Now click on Run , you will be able to see bearer token is passed as expected

In our next blog we will see how to create test plan in Azure portal

Please go ahead and join our discord channel ( to give some valuable feedbacks