((META (EMPTY-STRING title "API: Renew an access token") (WORD role "manual") (TAG-SET tags ("#api" "#manual" "#zettelstore")) (WORD syntax "zmk") (ZID-SET back ("00001010040700" "00001012000000")) (ZID-SET backward ("00001010040700" "00001012000000" "00001012920000" "00001012921000")) (NUMBER box-number "1") (STRING copyright "(c) 2020-present by Detlef Stern ") (TIMESTAMP created "20210126175322") (ZID-SET forward ("00001010040100" "00001012050200" "00001012920000" "00001012921000")) (WORD lang "en") (EMPTY-STRING license "EUPL-1.2-or-later") (TIMESTAMP modified "20230412160219") (TIMESTAMP published "20230412160219") (WORD visibility "public")) (BLOCK (PARA (TEXT "An access token is only valid for a certain duration.") (SOFT) (TEXT "Since the ") (LINK-ZETTEL () "00001012050200" (TEXT "authentication process")) (TEXT " will need some processing time, there is a way to renew the token without providing full authentication data.")) (PARA (TEXT "Send a HTTP PUT request to the ") (LINK-ZETTEL () "00001012920000" (TEXT "endpoint")) (TEXT " ") (LITERAL-INPUT () "/a") (TEXT " and include the current access token in the ") (LITERAL-INPUT () "Authorization") (TEXT " header:")) (VERBATIM-CODE (("" . "sh")) "# curl -X PUT -H 'Authorization: Bearer TOKEN' http://127.0.0.1:23123/a\n(\"Bearer\" \"eyJhbGciOiJIUzUxMiJ9.eyJfdGsiOjEsImV4cCI6MTY4MTMwNDA4NiwiaWF0IjoxNjgxMzA0MDI2LCJzdWIiOiJvd25lciIsInppZCI6IjIwMjEwNjI5MTYzMzAwIn0.kZd3prYc79dt9efDsrYVHtKrjWyOWvfByjeeUB3hf_vs43V3SNJqmb8k-zTHVNWOK0-5orVPrg2tIAqbXqmkhg\" 456)") (PARA (TEXT "You may receive a new access token, or the current one if it was obtained not a long time ago.") (SOFT) (TEXT "However, the lifetime of the returned ") (LINK-ZETTEL () "00001012921000" (TEXT "access token")) (TEXT " is accurate.")) (PARA (TEXT "If ") (LINK-ZETTEL () "00001010040100" (TEXT "authentication is not enabled")) (TEXT " and you send a renew request, no checking is done and you receive an artificial token immediate, without any delay:")) (VERBATIM-CODE (("" . "sh")) "# curl -X PUT -H 'Authorization: Bearer freeaccess' http://127.0.0.1:23123/a\n(\"Bearer\" \"freeaccess\" 316224000)") (PARA (TEXT "In this case, it is even possible to omit the access token.")) (HEADING 1 () "http-status-codes" "http-status-codes" (TEXT "HTTP Status codes")) (DESCRIPTION ((LITERAL-INPUT () "200")) (BLOCK (BLOCK (PARA (TEXT "Renew process was successful, the body contains a ") (LINK-ZETTEL () "00001012921000" (TEXT "list")) (TEXT " with the relevant data.")))) ((LITERAL-INPUT () "400")) (BLOCK (BLOCK (PARA (TEXT "The renew process was not successful.") (SOFT) (TEXT "There are several reasons for this.") (SOFT) (TEXT "Maybe access bearer token was not valid.")) (PARA (TEXT "Probably you should ") (LINK-ZETTEL () "00001012050200" (TEXT "authenticate")) (TEXT " again with user identification and password.")))))))