Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Connection with InfluxDB needs Authorization API key, not user/password authentification (βœ“ Sandbox Passed) #46

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions src/http.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class HttpService {
};

if(this.context.version == 2) {
// For InfluxDB version 2.x
axiosOptions.auth = {
username: this.context.username,
password: this.context.password,
// Setting Authorization header for API token-based authentication
if(this.context.apiToken) {
axiosOptions.headers = {
Authorization: `Token ${this.context.apiToken}`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'template literal syntax' is only available in ES6 (use 'esversion: 6').

};
}
}

Expand All @@ -29,14 +30,19 @@ class HttpService {

_buildInfluxDBUrl(path='write') {
const url = `http://${this.context.server}:${this.context.port}/${path}`;
const params = {
db: this.context.name,
u: this.context.username,
p: this.context.password,
};

let params = {};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

if(this.context.version == 1 && this.context.username && this.context.password) {
params = {
db: this.context.name,
u: this.context.username,
p: this.context.password,
};
} else if(this.context.version == 2) {
params = {
db: this.context.name
};
}
const paramsQuerystring = querystring.stringify(params);

const connectionUrl = `${url}?${paramsQuerystring}`;
return connectionUrl;
}
Expand Down Expand Up @@ -79,6 +85,11 @@ class HttpService {
u: this.context.username,
p: this.context.password,
};
} else if (this.context.version == 2) {
const params = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

bucket: this.context.name,
org: this.context.org,
};
const paramsQuerystring = querystring.stringify(params);
url = `/write?${paramsQuerystring}`;
} else {
Expand Down