# The taClient.addAuthorizedUser() method
This documents the `taClient.addAuthorizedUser()` method.

<div class="info-box">
    <span class="material-icons">info</span>
    <div>
        <strong>Async:</strong> This is a method you would want to use await with
    </div>
</div>

This method has input parameters. The function could easily be defined as:
```ts
async function addAuthorizedUser(tournamentId: string, discordId: string, roleIds: string[]): Promise<Response> {
    // backend logic
}
```
## General usage:
```ts
const response: Response = taClient.addAuthorizedUser(tournamentGuid, userDiscordId, ['roleId1', 'roleId2'])
```

The `response` variable from above will actually be a 'mashup' of two types. Firstly, the standard `Response` type. Secondly the `Response_AddAuthorizedUser`. Find the custom response object below.

```js
{
    details: {
        addAuthorizedUser: Response_AddAuthorizedUser,
        oneofKind: 'addAuthorizedUser'
    },
    respondingToPacketId: 'packet-guid-uuidv4',
    type: Response_ResponseType
}
```
- For `Response` please find documentation at [Modals -> Response](/documentation#Modals/4-Response)
- For `Response_AddAuthorizedUser` please find documentation at [Modals -> Response_AddAuthorizedUser](/documentation#Modals/4-Response_AddAuthorizedUser).

<div class="info-box">
    <span class="material-icons">info</span>
    <div>
        <strong>Note:</strong> The method uses role.roleId, not role.guid.
    </div>
</div>

```ts
// This is some base data about the user passed on from the popup where we add the authorised user
const userData = event.detail;
// Log the user data that is passed on
console.log('Adding user:', userData);

try {
    // Try to add the authorised user given their discord / platform id to the tournament with the selected roles
    let addAuthorizedUserResult = await client.addAuthorizedUser(tournamentGuid, userData.discordId, userData.roleIds);
    
    // If successful, add to the authorizedUsers array
    if (addAuthorizedUserResult.type === Response_ResponseType.Success) {
        authorizedUsers = [...authorizedUsers, userData];
    }
} catch (err) {
    console.error('Error adding user:', err);
    // If there is an error, display it and tell the user to show us the data passed on from the popup.
    error = "Failed to add user, please view console, screenshot it and send it to serverbp or matrikmoon on Discord.";
}
```
<div class="info-box">
    <span class="material-icons">info</span>
    <div>
        <strong>Example:</strong> A direct example is not available, as this function is not used in ShyyTAUI.
    </div>
</div>