diff --git a/docs/api/Authentication.md b/docs/api/Authentication.md index 3c54581..7097641 100644 --- a/docs/api/Authentication.md +++ b/docs/api/Authentication.md @@ -14,27 +14,7 @@ All API calls require an access token. You can get an access token by making a P === "fetch" ```javascript - const accessToken = (async _ => { - const loginInit = { - method: "POST", - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ "username": USERNAME, "password": PASSWORD}) - }; - - let loginResponse = await fetch("{{ production_url }}/api/login", loginInit); - let data = await loginResponse.json(); - - if (data === null){ - return false; - } - - if (!loginResponse.ok){ - console.error(`Login failed. Got code ${loginResponse.status} (${loginResponse.statusText})`); - return false; - } - - return data.access_token || false; - })(); + {% include 'api/get_access_token.js' %} ``` === "cURL" @@ -144,7 +124,7 @@ To refresh your access token, make a POST request to the `/api/tokens/refresh` e === "fetch" ```javascript const newAccessToken = (async _ => { - const csrf_refresh_token = some_func_to_get_csrf_token(); + const csrf_refresh_token = some_func_to_get_csrf_token_cookie(); const refreshInit = { method: "POST",