---
title: "Change Username | Speedscale Docs"
description: "Change usernames in test environments with Speedscale by transforming production usernames into test usernames for accurate API testing and traffic replay."
canonical: "https://docs.speedscale.com/guides/replay/change-login/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/replay/change-login/index.md) | [Canonical page](https://docs.speedscale.com/guides/replay/change-login/)

# Change Username

Generally speaking, login credentials in test environments may not match production logins. This example shows you how to change a production credential (such as a `client_id` or username) into a test environment value.

Keep in mind that this is typically not necessary if you are using the Speedscale Responders. If the Responder is mocking the connection between the Service Under Test (SUT) and the authentication service, it will provide the same list of valid users as the production system because that's what it recorded in production. However, this example is provided in case you are unable to record the interactions between the SUT and the authentication service.

<a id="objective"></a>

## Objective

Change a credential recorded in production to a test value. The Configuration section below shows the selected field, the Constant step, and the resulting transform chain.

The image shows a synthetic banking login: **JSON Path** selects `usernameOrEmail`, and **Constant** replaces it with `new_username`. The `/oauth/token` walkthrough below applies the same steps to `client_id`.

![A synthetic login identity selected with JSON Path and replaced by the Constant step](https://docs.speedscale.com/assets/images/change-login-prepare-04181776c6cb886135c5deb09a1df502.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/change-login-prepare-04181776c6cb886135c5deb09a1df502.jpg)

<a id="install-demo"></a>

### Install Demo

The data necessary for this example can be found in the Speedscale github repository:

```text
git clone https://github.com/speedscale/mock-lab
```

After you have downloaded the demo, follow the instructions in the `languages/go` directory (`cd mock-lab/languages/go` and `go run .`) to run the app and start capturing traffic. The mock-lab app authenticates through the `POST /oauth/token` endpoint, which returns an `access_token` used as a bearer token on subsequent calls. Send a credentialed token request whose body carries the login values you want to transform, for example:

```text
{
    "grant_type": "client_credentials",
    "client_id": "admin",
    "client_secret": "pass"
}
```

> **Note:** The mock-lab `/oauth/token` handler does not require these fields to issue a token, so you can supply whatever credential body fits your own auth flow. The point of this example is to show transforming a credential field (here `client_id`) in the login request body; pick whichever field carries the identity value in your environment.

Find this traffic in the traffic viewer, and then use the `Save` button to create a snapshot with this traffic. The screenshot below filters to the synthetic banking login endpoint instead of `/oauth/token`.

![The Traffic viewer filtered to banking-user and the /api/users/login endpoint, listing inbound POST login requests](https://docs.speedscale.com/assets/images/change-login-traffic-bd356ac3fbd788411df2ed47e47f453c.png)

<a id="configuration"></a>

### Configuration

From the snapshot page, select the `Traffic` tab and you can see your set of `Tests` requests that will be sent to the server, and `Mocks` transactions to mock out downstream calls. This is how to create this transform:

*   Select the `/oauth/token` transaction
*   Click on the `Request` tab to see the request body
*   Click on the pencil next to `client_id` and choose `Modify`

The screenshots in this section show the same steps on a different login request.

![Select](https://docs.speedscale.com/assets/images/change-login-select-6cee4daf031f1ce4a975e36bb812fe6d.png)

This will open the transform chain on the `Prepare` tab and you can see it has already selected the JSON Path for your `client_id` key. Now click the `+ Add step` button and you will see a list of options:

![Transform List](https://docs.speedscale.com/assets/images/change-login-transform-list-3333ef609c72058c1ca1665421b38ca3.png)

You can see there are many different options available, but for this example select the `Constant` transform which lets you supply your own value, then click `Done`. You can visually see exactly how this value will change by looking at `Replay uses` under the chain. Now click `Save and reanalyze` to save the chain, and the snapshot will update.

![Transform Chains](https://docs.speedscale.com/assets/images/change-login-transform-chains-eeccb26fbd1a72439c956882deab3ffb.png)

On the `Traffic` tab, the `Changes` column of the `/oauth/token` transaction now shows that there are transforms applied to that specific request. Now you can run this snapshot to see what the results look like. Try it out on your own snapshot!

info

Join slack.speedscale.com to ask real time questions. Our expert engineers are always happy to help with configuration issues.
