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

Passing API key with headers #171

Merged
merged 1 commit into from
Apr 19, 2023
Merged
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
16 changes: 9 additions & 7 deletions lib/webpagetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function get(config, pathname, proxy, agent, callback, encoding) {
}

if (encoding !== "binary") {
options.headers["X-WPT-API-KEY"] = this.config.key;
options.headers["accept-encoding"] = "gzip,deflate";
options.headers["User-Agent"] = "WebpagetestNodeWrapper/v0.6.0";
}
Expand Down Expand Up @@ -338,9 +339,10 @@ function getTestBalance(options, callback) {
options = options === callback ? undefined : options;

var query = helper.setQuery(mapping.commands.testBalance, options);
if (!query.k && this.config.key) {
query.k = this.config.key;
}
// API key (to pass with the parans) (depricated)
// if (!query.k && this.config.key) {
// query.k = this.config.key;
// }
return api.call(this, paths.testBalance, callback, query, options);
}

Expand All @@ -366,10 +368,10 @@ function runTest(what, options, callback) {
// json output format
query.f = "json";

// API key
if (!query.k && this.config.key) {
query.k = this.config.key;
}
// API key (to pass with the parans) (depricated)
// if (!query.k && this.config.key) {
// query.k = this.config.key;
// }

// synchronous tests with results
var testId,
Expand Down