---
title: "POST /api/v1/auth"
method: POST
path: "/api/v1/auth"
tags: ["auth"]
---

# POST /api/v1/auth

`POST /api/v1/auth`

## Request

- Base URL: `https://prices.openfoodfacts.org` (the document declares no server; this is the origin it was published from)
- URL: `https://prices.openfoodfacts.org/api/v1/auth`
- Auth: none declared

Authentication: provide username/password or a keycloak access_token
and get a bearer token in return.

- **username**: Open Food Facts user_id (not email)
- **password**: user password (clear text, but HTTPS encrypted)

- **access_token**: keycloak access_token (clear text)

A **token** is returned. If the **set_cookie** parameter is set to 1,
the token is also set as a cookie named "opsession" in the response.

To authenticate, you can either:
- use the **Authorization** header with the **Bearer** scheme,
e.g.: "Authorization: bearer token"
- use the **opsession** cookie, e.g.: "Cookie: opsession=token"

## Query parameters

- `set_cookie` 1

## Request body `application/x-www-form-urlencoded`

- Login
  - `username` string
  - `password` string
  - `access_token` string

## Response `200`

- SessionResponse
  - `user_id` string, required
  - `is_moderator` boolean, required
  - `access_token` string, required
  - `token_type` string, required

## Changes

- **2026-10-19** `d9a89336fcb5`: 1 info
  - added the new optional `query` request parameter `set_cookie`
- **2026-07-13** `f1bb01adae9b`: 11 info
  - added the new optional request property `access_token` (media type: application/x-www-form-urlencoded)
  - added the new optional request property `access_token` (media type: multipart/form-data)
  - request body became optional
  - the request property `password` became optional (media type: application/x-www-form-urlencoded)
  - …7 more

[Operation history](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-prices-rest-api/changes/api/v1/auth/post.md)

---

[API](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-prices-rest-api.md) - [All operations](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-prices-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/openfoodfacts/apis/open-food-facts-open-prices-rest-api/revisions/d7c5d8b4c32e?raw)
