> For the complete documentation index, see [llms.txt](https://docs.idosgames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idosgames.com/api/api-v1/authentication.md).

# Authentication

This endpoint is used to authenticate users and perform various actions such as device login, email login, and registration.

UR&#x4C;**:** `https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/`

## LoginWithDeviceID

**Purpose:** Allows a user to log in using their device ID.\
\
**URL:**&#x20;

{% code overflow="wrap" %}

```
https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/LoginWithDeviceID
```

{% endcode %}

**Method:** `POST`

**Request Parameters (JSON body)**

* `deviceID` (string): The unique identifier of the user's device.
* `platform` (string): The platform the device is running on (e.g., Android, iOS).
* `device` (string): Information about the device (e.g., model or type).
* `ip` (string, optional): The user's IP address.
* `userName` (string, optional): The user's username.

**Responses**

* **200 OK**: Successful login. Returns a `GetAllUserDataResult` object with user data.
* **400 Bad Request**: Incorrect request parameters. Returns an error message, e.g., "INVALID\_INPUT\_DATA".

**Example Usage**

**Request:**

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/LoginWithDeviceID', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        DeviceID: 'unique-device-id',  
        Platform: 'Android',  
        Device: 'Samsung Galaxy S21',  
        UserName: 'exampleUser'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response:**

{% code lineNumbers="true" %}

```json
{
    "UserID": "generated-user-id",
    "CustomUserData": {
        "DataVersion": 1,
        "Data": {}
    },
    ...
}
```

{% endcode %}

***

## LoginWithEmail

**Purpose:** Allows a user to log in using their email and password.\
\
**URL:**&#x20;

{% code overflow="wrap" %}

```
https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/LoginWithEmail
```

{% endcode %}

**Method:** `POST`

**Request Parameters (JSON body)**

* `email` (string): The user's email address.
* `password` (string): The user's password.

**Responses**

* **200 OK**: Successful login. Returns a `GetAllUserDataResult` object with user data.
* **400 Bad Request**: Incorrect request parameters or invalid credentials. Possible messages: "INVALID\_INPUT\_DATA", "USER\_NOT\_FOUND", "INCORRECT\_PASSWORD".

**Example Usage**

**Request:**

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/LoginWithEmail', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        email: 'user@example.com',  
        password: 'securepassword'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response:**

{% code overflow="wrap" lineNumbers="true" %}

```json
{  
    "UserID": "existing-user-id",  
    "CustomUserData": {  
        "DataVersion": 1,  
        "Data": {}  
    },  
    ...  
}  
```

{% endcode %}

***

## AddEmailAndPassword

**Purpose:** Adds an email and password to an existing user's account.\
\
**URL:**&#x20;

{% code overflow="wrap" %}

```
https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/AddEmailAndPassword
```

{% endcode %}

**Method:** `POST`

**Request Parameters (JSON body)**

* `userID` (string): The user's unique identifier.
* `email` (string): The email address to be added.
* `password` (string): The password to be added.
* `clientSessionTicket` (string): The session ticket for authenticating the current session.

**Responses**

* **200 OK**: Operation successful. Returns a success message.
* **400 Bad Request**: Incorrect request parameters or validation error. Possible messages: "INVALID\_INPUT\_DATA", "USER\_NOT\_FOUND", "SESSION\_EXPIRED", "INVALID\_SESSION\_TICKET", "EMAIL\_ALREADY\_EXISTS", "FAILED\_TO\_SAVE\_TO\_DATABASE".

**Example Usage**

**Request:**

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/AddEmailAndPassword', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        userID: 'existing-user-id',  
        email: 'newemail@example.com',  
        password: 'newpassword',  
        clientSessionTicket: 'valid-session-ticket'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

{% endcode %}

{% endtab %}
{% endtabs %}

**Response:**

{% code overflow="wrap" lineNumbers="true" %}

```json
{
    "Message": "SUCCESS"
}
```

{% endcode %}

***

## RegisterUserByEmail

**Purpose:** Registers a new user using their email and password.

**URL:**&#x20;

{% code overflow="wrap" %}

```
https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/RegisterUserByEmail
```

{% endcode %}

**Method:** `POST`

**Request Parameters (JSON body)**

* `email` (string): The email address for registration.
* `password` (string): The password for the new account.
* `platform` (string): The user's platform.
* `device` (string): The user's device information.
* `deviceID` (string): The user's device ID.
* `ip` (string, optional): The user's IP address.
* `userName` (string, optional): The user's username.

**Responses**

* **200 OK**: Successful registration. Returns a `GetAllUserDataResult` object with new user data.
* **400 Bad Request**: Incorrect request parameters or email already in use. Possible messages: "INVALID\_INPUT\_DATA", "EMAIL\_ALREADY\_EXISTS", "REGISTRATION\_FAILED".

**Example Usage**

**Request:**

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Authentication/RegisterUserByEmail', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        email: 'newuser@example.com',  
        password: 'securepassword',  
        platform: 'iOS',  
        device: 'iPhone 13',  
        deviceID: 'unique-device-id'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response:**

{% code overflow="wrap" lineNumbers="true" %}

```json
{
    "UserID": "new-generated-user-id",  
    "CustomUserData": {  
        "DataVersion": 1,  
        "Data": {}  
    },  
    ...  
}
```

{% endcode %}
