---
title: "Login to application"
method: POST
path: "/login"
---

# Login to application

`POST /login`

Supports both json and form request types. If the caller is already logged in, then in the form case, they are redirected to SECURITY_POST_LOGIN_VIEW, for a json request, a 400 is returned.

## Query parameters

- `next` string
- `include_auth_token` string

## Request body

- Login
  - `email` string, required — user email
  - `password` string, required — Password
  - `remember` boolean — If true, will remember userid as part of cookie. There is a configuration variable DEFAULT_REMEMBER_ME that can be set. This field will override that.

## Response `200`

Login response

- object — The user successfully signed in using their primary credential. Note that depending on SECURITY_TWO_FACTOR configuration variable, a second form of authentication might be required prior to the user being fully authenticated. `tf_required` will be set to True in this case. Note that if 2FA is not configured, only the ``tf_required`` property (=False) will be returned.
  - `meta` object, required
    - `code` integer, required — Http status code
  - `response` object, required
    - `user` object — By default an empty dictionary is returned. However by overriding _User::get_security_payload()_ any attributes of the User model can be returned.
      - `authentication_token` string — Token to be used in future token-based API calls. Note this only returned from those APIs that accept a 'include_auth_token' query param.
      - `refresh_token` string — A refresh token that can be used to get a new auth token. This is only returned if the application has enabled refresh tokens.
    - `csrf_token` string — Session CSRF token
    - `tf_required` boolean — True if two-factor authentication is required for caller.
    - `tf_state` string — if "setup_from_login" then the caller must go through two-factor setup endpoint. If "ready" then a code has been sent and should be supplied to SECURITY_TWO_FACTOR_TOKEN_VALIDATION_URL.
    - `tf_method` string — Which method was used to send code.
    - `tf_select` boolean — If user has setup multiple forms of two-factor authentication, this will be True and the application should prompt the user for which method they want to use.
    - `tf_setup_methods` string[]

## Other responses

- `302` — If the caller is already authenticated, the form contents is ignored and a redirect is done: redirect(SECURITY_POST_LOGIN_VIEW) (note that 'next' is ignored). If the caller is NOT already authenticated, and the form contents are validated the caller will be redirected to: redirect(next) or redirect(SECURITY_POST_LOGIN_VIEW)
- `400` — Errors while validating login, or caller already authenticated/logged in.

---

[API](https://skmtc.net/pallets-eco/apis/flask-security-external-api.md) · [All operations](https://skmtc.net/pallets-eco/apis/flask-security-external-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pallets-eco/flask-security-external-api/versions/5ee7c28d6e1e/schema)
