Can't Authenticate into FlightXML3 using JS


#1

[UPDATE: Here’s the fix. I don’t know if you want to update your documentation. Not showing what the client_options needed is what caused the problem.]

var username = process.env.FLIGHTAWARE_USER;
var key = process.env.FLIGHTAWARE_API3;

var Client = require(‘node-rest-client’).Client;
var options_auth = { user: username, password: key };
var client = new Client(options_auth);
var fxmlUrl = ‘https://flightxml.flightaware.com/json/FlightXML3/’;
client.registerMethod(‘findFlights’, fxmlUrl + ‘FindFlight’, ‘GET’);
var findFlightArgs = {
parameters: {
origin: ‘SJC’,
destination: ‘DEN’,
type: ‘nonstop’
}
};
client.methods.findFlights(findFlightArgs, function (data, response) {
console.log(data);
});

I can’t seem to authenticate into FlightAware XML3. My environment is a vagrant box running a Docker instance for my Nginx server for testing purposes. Tried using the Request module and Node Rest Client. Here’s my code.

Any help would be appreciated. I’m at the Starter level. Thanks.


#2

Hi B,
I would like to Use Ajax or some front-end version to authenticate into FlightAware (instead of nodeJS, which is back-end). I don’t know how to wrap an API around my local implementation to query your servers. Where can I please find the code to set this up?

Thanks,
Felicia


#3

If you believe you have an improvement to one of our FlightXML3 examples, we welcome Pull Requests on github.