Add support for api_key authentication

This commit is contained in:
Matt Aitken
2023-02-19 19:17:41 +00:00
parent ac1354b71a
commit fe598ff713
@@ -45,7 +45,16 @@ export function applyCredentials(
case "api_key": {
const authConfig = authentication[credentials.name];
if (authConfig.placement.in === "header") {
fetch.headers[authConfig.placement.key] = credentials.api_key;
let value = "";
switch (authConfig.placement.type) {
case "basic":
value = `Basic ${credentials.api_key}`;
break;
case "bearer":
value = `Bearer ${credentials.api_key}`;
break;
}
fetch.headers[authConfig.placement.key] = value;
}
return fetch;
}