Auth only supporting api key, not access tokens or username/password
skovhus opened this issue · 1 comments
skovhus commented
Currently the library always uses the setApiKeyToObject method to set up authentication. Which effectively means that the library can only be used with an API Key, and not when using username/password or access tokens (through OAuth).
This seems like a bug, as the common code paths already has functionality like setBasicAuthToObject and setBearerAuthToObject.
The fix is fairly simple, we just need to replace all calls to setApiKeyToObject with something more generic like addAuthToObject:
const addAuthToObject = function (object, keyParamName, configuration) {
if (!configuration) {
return
}
if (configuration.apiKey) {
setApiKeyToObject(object, keyParamName, configuration);
} else if (configuration.username || configuration.password) {
setBasicAuthToObject(object, configuration);
} else if (configuration.accessToken) {
setBearerAuthToObject(object, configuration);
}
};As the code here seems auto-generated, I'm not sure if I can submit a PR.