> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sportsxapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Auth & 2FA

> Auth & 2FA operations on the STX Python SDK.

**6 operations.** See the [auth & 2fa guide](/sdks/python/authentication) for worked examples.

## `confirm2_fa`

*Mutation — returns `LoginResult`.*

<sub>GraphQL field: `confirm2Fa`</sub>

User submitting the 2FA code in order to login.

**Parameters**

| Name         | Type  | Required | Description                                                    |
| ------------ | ----- | -------- | -------------------------------------------------------------- |
| `code`       | `str` | Yes      | The 2FA code that was sent to the user by email.               |
| `session_id` | `str` | Yes      | The id of the session to confirm 2FA for.                      |
| `timestamp`  | `int` | No       | The timestamp of the confirmation.                             |
| `email`      | `str` | Yes      | The email of the user that the confirmation is being made for. |

**Example**

```python theme={null}
result = client.confirm2_fa(params={"code": ..., "session_id": ..., "timestamp": ..., "email": ...}, selections=Selection(...))
```

***

## `login`

*Mutation — returns `LoginResult`.*

Login to the platform using the credentials. Please note that if the user has 2FA enabled
the actual login will occur when the 2FA code is confirmed in another call to the API.

**Parameters**

| Name          | Type                                  | Required | Description                                    |
| ------------- | ------------------------------------- | -------- | ---------------------------------------------- |
| `credentials` | `LoginCredentials` (dict — see below) | Yes      | The credentials to use to log into the system. |

`credentials` accepts a dict with these keys (pass as `params={"credentials": {...}}`):

| Field         | Type         | Required | Description                                                      |
| ------------- | ------------ | -------- | ---------------------------------------------------------------- |
| `email`       | `str`        | No       | The email of the user.                                           |
| `username`    | `str`        | No       | The username of the user.                                        |
| `password`    | `str`        | Yes      | The password for the given email username.                       |
| `device_info` | `DeviceInfo` | No       | The information about the device that the user is logging in on. |

**Example**

```python theme={null}
result = client.login(params={"credentials": ...}, selections=Selection(...))
```

***

## `logout`

*Mutation — returns `LogoutResult`.*

Logout of the platform on a specific device, invalidating all tokens.

**Parameters**

| Name          | Type                            | Required | Description                               |
| ------------- | ------------------------------- | -------- | ----------------------------------------- |
| `device_info` | `DeviceInfo` (dict — see below) | No       | The information on the device to log out. |

`device_info` accepts a dict with these keys (pass as `params={"device_info": {...}}`):

| Field       | Type  | Required | Description                                         |
| ----------- | ----- | -------- | --------------------------------------------------- |
| `device_id` | `str` | No       | The unique id of the device from the device itself. |

**Example**

```python theme={null}
result = client.logout(params={"device_info": ...}, selections=Selection(...))
```

***

## `new_token`

*Mutation — returns `LoginResult`.*

<sub>GraphQL field: `newToken`</sub>

Create a new authorization token from the user's refresh token.

**Parameters**

| Name            | Type  | Required | Description |
| --------------- | ----- | -------- | ----------- |
| `refresh_token` | `str` | Yes      | —           |

**Example**

```python theme={null}
result = client.new_token(params={"refresh_token": ...}, selections=Selection(...))
```

***

## `resend2_fa`

*Mutation — returns `TwoFactorAuthResult`.*

<sub>GraphQL field: `resend2Fa`</sub>

Request that another 2FA code be sent when apparently the user didnt get the code.

**Parameters**

| Name         | Type  | Required | Description                                                                      |
| ------------ | ----- | -------- | -------------------------------------------------------------------------------- |
| `session_id` | `str` | Yes      | The session id to resend the code for.                                           |
| `email`      | `str` | Yes      | The user id to resend the code for. The system will find the email for the user. |

**Example**

```python theme={null}
result = client.resend2_fa(params={"session_id": ..., "email": ...}, selections=Selection(...))
```

***

## `send2_fa`

*Mutation — returns `TwoFactorAuthResult`.*

<sub>GraphQL field: `send2Fa`</sub>

Request a new 2FA code providing the reason - i.e. updating user profile for example.

The reasons are enums defined above.

**Example**

```python theme={null}
result = client.send2_fa(selections=Selection(...))
```

***

## Types

Reusable dict shapes referenced by the operations above. Pass as plain Python dicts; the SDK translates snake\_case keys to the wire format.

### `DeviceInfo`

Contains information on a device registered in the system.

| Field       | Type  | Required | Description                                         |
| ----------- | ----- | -------- | --------------------------------------------------- |
| `device_id` | `str` | No       | The unique id of the device from the device itself. |
