From 76a5ff9547a2c2ea64ca9ff743841d35ad54ca88 Mon Sep 17 00:00:00 2001 From: cubicroot <github@cubicroot.xyz> Date: Wed, 25 Dec 2024 18:44:49 +0100 Subject: [PATCH] document API authentication --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index e4209e3b4..2ab712139 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Prodinstanz: <https://api.events.ccc.de/congress/2024/> | Kategorie | Endpunkt | GET | POST | PUT | DEL | Beschreibung | | ---------- | ---------------------------------------- | --- | ---- | --- | --- | ----------------------------------------------------- | +| Auth | `/auth/get-token` | | x | | | Ausstellen eines API-Tokens | | Persönlich | `/me` | x | | x | | eigenes Profil / Settings | | Persönlich | `/me/friends` | x | | x | x | Liste der Buddies | | Persönlich | `/me/badges` | x | | | | Liste aller Badges/Achievements | @@ -64,6 +65,20 @@ Prodinstanz: <https://api.events.ccc.de/congress/2024/> Per POST werden neue Einträge angelegt, per PUT bestehende verändert. Details zu den einzelnen Endpunkten folgen in Kürze™. +### API-Beispiel mit cURL + +Zuerst einen Token generieren: + +```bash +curl https://{API_URL}/api/auth/get-token -H "Content-Type: application/json" -X POST --data '{"username": "{USERNAME}", "passwort": "{PASSWORD}"}' +``` + +Mit diesem Token können dann Endpunkte aufgerufen werden die eine Authentifizierung erfordern: + +```bash +curl https://{API_URL}/api/me -H "Content-Type: application/json" -H "Authorization: Token {API_TOKEN}" +``` + ## Development see [Development.md](./Development.md) -- GitLab