summaryrefslogtreecommitdiff
path: root/web/source/lib/oauth.js
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-06-20 10:44:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-20 10:44:01 +0200
commitec81d28a7767f8dc7863114e9436098af751cd0e (patch)
treecb63583f55a20d3999fb47f77a8b28a4030fc931 /web/source/lib/oauth.js
parent[chore] make tests more cacheable by avoiding time.Now() (#656) (diff)
downloadgotosocial-ec81d28a7767f8dc7863114e9436098af751cd0e.tar.xz
[frontend] add Accept header to oauthed api requests (#657)
Diffstat (limited to 'web/source/lib/oauth.js')
-rw-r--r--web/source/lib/oauth.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/web/source/lib/oauth.js b/web/source/lib/oauth.js
index 673d4ce83..9cbf3d484 100644
--- a/web/source/lib/oauth.js
+++ b/web/source/lib/oauth.js
@@ -149,7 +149,7 @@ module.exports = function oauthClient(config, initState) {
return (state.access_token != undefined);
}
- function apiRequest(path, method, data, type="json") {
+ function apiRequest(path, method, data, type="json", accept="json") {
if (!isAuthorized()) {
throw new Error("Not Authenticated");
}
@@ -160,7 +160,8 @@ module.exports = function oauthClient(config, initState) {
url.search = s;
}
let headers = {
- "Authorization": `Bearer ${state.access_token}`
+ "Authorization": `Bearer ${state.access_token}`,
+ "Accept": accept == "json" ? "application/json" : "*/*"
};
let body = data;
if (type == "json" && body != undefined) {