---
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, they are logged out and the new user is logged in.

## Query parameters

- `next` string

## Request body

- Login
  - `email` string, required — user identifier. This is by default an email address, but can be any (unique) field that is part of the User model and is defined in the USER_IDENTITY_ATTRIBUTES configuration variable. It will also match against numeric User model fields.
  - `password` string, required — Password
  - `remember_me` 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

- DefaultJsonResponse
  - `user` object, required — By default just 'id', and 'authentication_token' are returned. However by overriding _User::get_security_payload()_ any attributes of the User model can be returned.
    - `id` integer, required — Unique user id (primary key)
    - `authentication_token` string — Token to be used in future token-based API calls.
  - `csrf_token` string — Session CSRF token

## Other responses

- `302` — Success or failure with form data body. redirect('next') or redirect(config_value('POST_LOGIN_VIEW'))
- `400` — Errors while validating login

## Changes

- **2019-07-23** `11c8459a5c04` — 2 breaking, 4 warning, 6 info
  - the response's body type changed from no type to `object` for status `200` (media type: application/json)
  - the `response/errors` response's property type changed from `array` to `object` for status `400`
  - deleted the `query` request parameter `include_auth_token`
  - removed the request property `remember` (media type: application/json)
  - …8 more

[Change history](https://skmtc.dev/pallets-eco/apis/flask-security-external-api/changes/login/post.md)

---

[API](https://skmtc.dev/pallets-eco/apis/flask-security-external-api.md) · [All operations](https://skmtc.dev/pallets-eco/apis/flask-security-external-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/pallets-eco/flask-security-external-api/revisions/11c8459a5c04/schema)
