# [JWT] Auth by username and password


Authenticates the user by the username/email and password specified.

Endpoint: POST /login
Version: v1

## Query parameters:

  - `projectId` (string, required)
    Login project ID from [Publisher Account](https://publisher.xsolla.com/).

  - `login_url` (string)
    URL to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the **Callback URL** specified in the **URL** block of [Publisher Account](https://publisher.xsolla.com/). For the scenario of a login error, the value should be identical to the the **Error callback URL** specified in the **URL** block of [Publisher Account](https://publisher.xsolla.com/). To find the settings, go to **Login > your Login project** and select the **Callback URLs** section in the upper block. **Required** if there are several Callback URLs.

  - `payload` (string)
    Your custom data. The value of the parameter will be returned in the `payload` claim of the **user JWT**. Recommended maximum length less than 500 characters. Note, that this parameter is only available if you use a custom user data storage.

  - `with_logout` (string)
    Shows whether to deactivate the existing user JWT values and activate the one generated by this call. Can have the following values:
* `1` to deactivate the existing values and activate a new one,
* `0` to keep the existing values activated.

## Request fields (application/json):

  - `password` (string, required)
    User password.

  - `remember_me` (boolean)
    Whether the user agrees to save the authentication data. Default is `false`.

  - `username` (string, required)
    Username or email address.

## Response 200 fields (application/json):

  - `login_url` (string, required)
    URL with the `token` and `remember_me` parameters to redirect the user to after successful authentication. The `token` value is the user JWT.

## Response 400 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 401 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 404 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 422 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 429 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

