---
agentTools:
  projectIndex: https://evolutionscript.readme.io/llms.txt
---

# User Login

The Bearer token is the access token requested in [Request Access Token](https://evolutionscript.readme.io/reference/request-access-token) page.

When you receive a success response, then your app will receive a new access token for user, but if account has enabled the Two-Factor authentication, you have to make a new authentication.

## Success login with no two-factor

Here is an example where you will receive a success response, two-factor authentication is not required so you can use the access token for user requests:

```json
{
  status: 'success',
  two_factor: false,
  access_token: 'UserAccessToken...'
}
```

## Success login with Two-Factor require

In this example, it's necessary to make a second authentication using the two-factor code, so you will receive an answer like this:

```json
{
  status: 'success',
  two_factor: true,
  access_token: 'twoFactorToken...'
}
```

The access\_token received will be used in the two-factor token.

> 📘 Two Factor token will be valid for 10 minutes

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Api with Access Token",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://yoursite.com/api/"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/user_token": {
      "post": {
        "summary": "User Login",
        "description": "",
        "operationId": "user-login",
        "parameters": [
          {
            "name": "Authentication",
            "in": "header",
            "description": "Ex: Bearer {access_token} should be replaced with the access token.",
            "required": true,
            "schema": {
              "type": "string",
              "default": "Bearer {access_token}"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "default": "userdemo"
                  },
                  "password": {
                    "type": "string",
                    "default": "userdemo"
                  },
                  "captcha_token": {
                    "type": "string",
                    "description": "Optional parameter in case you use image captcha."
                  },
                  "captcha": {
                    "type": "string",
                    "description": "Optional parameter in case you use image captcha."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Success (two factor not required)": {
                    "value": "{\n  status: 'success',\n  two_factor: false,\n  access_token: 'UserAccessToken...'\n}"
                  },
                  "Success (two factor requires)": {
                    "value": "{\n  status: 'success',\n  two_factor: true,\n  access_token: 'twoFactorToken...'\n}"
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n\tstatus: 'error',\n  message: 'invalidlogindetails'\n}"
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "security": []
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "65bd0d9a8cfebc004220b8d8:65bd1735b10279002a44afd9"
}
```