From 867c3207c5bf4953c3232989f1bab0a9e9275795 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Thu, 18 Oct 2018 22:22:40 +0200 Subject: [PATCH] #246: CURL examples for API authentication --- docs-web/src/main/webapp/header.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs-web/src/main/webapp/header.md b/docs-web/src/main/webapp/header.md index 64d86490..fadfe52c 100644 --- a/docs-web/src/main/webapp/header.md +++ b/docs-web/src/main/webapp/header.md @@ -27,20 +27,23 @@ All dates are returned in UNIX timestamp format in milliseconds. ## Authentication #### **Step 1: [POST /user/login](#api-User-PostUserLogin)** -A call to this endpoint will return a cookie header like this: +A call to this endpoint will return a cookie header. Here is a CURL example: ``` -HTTP Response: +curl -i -X POST -d username=admin -d password=admin https://docs.mycompany.com/api/user/login Set-Cookie: auth_token=64085630-2ae6-415c-9a92-4b22c107eaa4 ``` #### **Step 2: Authenticated API calls** -All following API calls must have a cookie header supplying the given token, like this: +All following API calls must have a cookie header supplying the given token. Here is a CURL example: ``` -HTTP Request: -Cookie: auth_token=64085630-2ae6-415c-9a92-4b22c107eaa4 +curl -i -X GET -H "Cookie: auth_token=64085630-2ae6-415c-9a92-4b22c107eaa4" https://docs.mycompany.com/api/document/list +{"total":12,"documents":[...]} ``` #### **Step 3: [POST /user/logout](#api-User-PostUserLogout)** A call to this API with a given `auth_token` cookie will make it unusable for other calls. +``` +curl -i -X POST -H "Cookie: auth_token=64085630-2ae6-415c-9a92-4b22c107eaa4" https://docs.mycompany.com/api/user/logout +``` \ No newline at end of file