# Azure Load Testing Series - Accessing bearer token in Jmeter between different thread groups using BeanShell Assertion
## About this blog
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
-------------------
## Mock API
In order to cover the scenarios, I have used a mock API that exposes token endpoint and a dummy GET endpoint.
- Mock API
- Mock Oauth Token endpoint
-------------------
## Extract token between two thread groups using BeanShell assertions
### Creating two thread groups
- Now we can move our existing "Get access token" HTTP request to newly created thread group

### Create BeanShell assertion
- 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
```cmd
props.put("access_token", vars.get("auth_token"));
```

### Create BeanShell PreProcessor
- 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
```cmd
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

-------------------
## Next steps
In our next blog we will see how to create test plan in Azure portal
-------------------
## Join us
Please go ahead and join our discord channel (https://discord.gg/8Cs82yNS) to give some valuable feedbacks
## Sponsor