Skip to content

Commit

Permalink
Replace token with include
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 1, 2021
1 parent f631916 commit f52d74f
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions docs/api/Authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f52d74f

Please sign in to comment.