use Bearer auth instead of Basic

this was a relic from the python version, i'd modeled the auth code off
some random blog post back then.
This commit is contained in:
Harvey Tindall
2020-11-12 21:04:35 +00:00
parent ba601935b5
commit d64e98da37
6 changed files with 147 additions and 157 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ export const _get = (url: string, data: Object, onreadystatechange: () => void):
let req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = 'json';
req.setRequestHeader("Authorization", "Basic " + btoa(window.token + ":"));
req.setRequestHeader("Authorization", "Bearer " + btoa(window.token));
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
req.onreadystatechange = onreadystatechange;
req.send(JSON.stringify(data));
@@ -60,7 +60,7 @@ export const _post = (url: string, data: Object, onreadystatechange: () => void,
if (response) {
req.responseType = 'json';
}
req.setRequestHeader("Authorization", "Basic " + btoa(window.token + ":"));
req.setRequestHeader("Authorization", "Bearer " + btoa(window.token));
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
req.onreadystatechange = onreadystatechange;
req.send(JSON.stringify(data));
@@ -69,7 +69,7 @@ export const _post = (url: string, data: Object, onreadystatechange: () => void,
export function _delete(url: string, data: Object, onreadystatechange: () => void): void {
let req = new XMLHttpRequest();
req.open("DELETE", url, true);
req.setRequestHeader("Authorization", "Basic " + btoa(window.token + ":"));
req.setRequestHeader("Authorization", "Bearer " + btoa(window.token));
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
req.onreadystatechange = onreadystatechange;
req.send(JSON.stringify(data));