Authorization required error

Hi,

When we try to call SOAP services using our username and api key we are getting below message.
Username : HtsGdc

Please help me

Service response :

SoapFault Object ( [message:protected] => Authorization Required [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\xampp\htdocs\faware.php [line:protected] => 12 [trace:Exception:private] => Array ( [0] => Array ( [function] => __doRequest [class] => SoapClient [type] => → [args] => Array ( [0] => KAUS [1] => flightxml.flightaware.com/soap/FlightXML2/op [2] => FlightXML2:Metar [3] => 1 [4] => 0 ) ) [1] => Array ( [file] => C:\xampp\htdocs\faware.php [line] => 12 [function] => __call [class] => SoapClient [type] => → [args] => Array ( [0] => Metar [1] => Array ( [0] => Array ( [airport] => KAUS ) ) ) ) [2] => Array ( [file] => C:\xampp\htdocs\faware.php [line] => 12 [function] => Metar [class] => SoapClient [type] => → [args] => Array ( [0] => Array ( [airport] => KAUS ) ) ) ) [previous:Exception:private] => [faultstring] => Authorization Required [faultcode] => HTTP )

Did you generate the interface stubs by running the command-line “wsdl.exe” utility, or by using the Visual Studio GUI to add the web service? Only the first method is known to work.

We are using PHP SOAP method.How can we solve the problem here?

Sorry, I thought you were using C#. For PHP, you should be able to initialize the SoapClient object with your username and API Key for the password.


$options = array(
                 'trace' => true,
                 'exceptions' => 0,
                 'login' => 'sampleUser',
                 'password' => 'abc123abc123abc123abc123abc123abc123',
                 );
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options);


Hi,

We are also receiving a Authorization Required error.

username: richardhardy


HTTP/1.1 401 Authorization Required
WWW-Authenticate: Basic realm=“FlightXML2b”
Vary: Accept-Encoding
Content-Type: text/html;charset=utf-8
Content-Length: 211
Accept-Ranges: bytes
Date: Thu, 24 Sep 2015 14:16:18 GMT
X-Varnish: 1917452487
Age: 0
Via: 1.1 varnish
Connection: close
Server: FlightAware/3.1
X-FA-Cache: MISS
cache-control: max-age=5, must-revalidate

Authentication Required

Authentication Required


Please assist as this has now become a service issue for us.

Many Thanks

Chris

Hi All,

Can someone please reply to my question in the topic ‘Authorization required error’… This is a business critical issue for us now and it seems quite strange there is no direct contact for API support from your company.

Regards

Hi Chris,

Our FlightXML developer is out of the office, however, I have reached out to him and created a ticket for him to look into your issue. The ticket id is (FB54735).

Please ensure you are passing the api key as the password part of the authentication, and not your account’s website password.

Has your application previously been working with the same credentials, or is this a new app? What language is it developed in, and can you share a small part of it that sends the request?

Hi,

Nothing at all has changed at our end of things in terms of what we pass through in the request, it has just stopped working.

I can confirm it is certainly the API key we pass to you. I can still use this to log in to the FlightXML section via a browser and perform a manual lookup, it is just the API that has stopped working recently (and has been fine since 2012). Have you changed anything at your end?

We use a piece of software called Omnis Studio which is essentially its own language. this performs a HTTP POST / HTTP Read request (see below)

POST flightxml.flightaware.com/soap/FlightXML2b/op HTTP/1.1
Host: flightxml.flightaware.com
Authorization: Basic ********************************************** Date: 28 SEP 2015
Expires: 29 SEP 2015
Connection: close
Server: Freedom.SOAP
Cache-control: no-cache
Content-Type: text/xml;charset=utf-8
Content-length: 476
SOAPAction: FlightXML2b:FlightInfoStatus

<?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xs=“XML Schema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:flig=“http://flightxml.flightaware.com/soap/FlightXML2b”>
soap:Body
flig:FlightInfoStatusRequest
flig:identBAW697</flig:ident>
flig:howMany</flig:howMany>
flig:offset</flig:offset>
</flig:FlightInfoStatusRequest>
</soap:Body>
</soap:Envelope>

I have removed the authentication string for security purposes.

Regards

Chris

There were no FlightXML-specific changes deployed in the last month.

You say you are able to do FlightXML requests manually via your browser without problems though? Using JSON, I assume?

Hi,

Yes, I was still able to using JSON.

The thing is, since 2012 nothing has changed at our end either regarding this interface either and now it has stopped.

Can you please tell me what the error I have submitted further up this post means? It seems to be everything is connecting but that the authorization is failing at your end.

Maybe our API key has changed / expired…? Can you confirm this somehow or issue us a new one?

Do you have an email address that I can contact you on? Waiting for a reply on here is excruciatingly slow and this has been a business critical issue for us for almost a week now!!

Thanks

Can you tell me if the XML structure we are using is still in the correct format?

???

Yes, your sample request is in the correct format and still works in our testing using even the command-line “wget” utility. Are you sure you have not upgraded any system or library dependencies on your side?


$ wget -O- --post-file=test.xml --user=richardhardy --password=xxxxxxxxxx --header="SOAPAction: FlightXML2b:FlightInfoStatus" --header="Content-type: text/xml;charset=utf-8" http://flightxml.flightaware.com/soap/FlightXML2b/op
--2015-10-01 16:24:30--  http://flightxml.flightaware.com/soap/FlightXML2b/op
Resolving flightxml.flightaware.com (flightxml.flightaware.com)... 70.42.6.250
Connecting to flightxml.flightaware.com (flightxml.flightaware.com)|70.42.6.250|:80... connected.
HTTP request sent, awaiting response... 401 Authorization Required
Reusing existing connection to flightxml.flightaware.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 84292 (82K) [text/xml]
Saving to: ‘STDOUT’

-                                                                                  0%                                                                                                                                                                                                          ]       0  --.-KB/s             <?xml version="1.0"  encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:FlightXML2b="http://flightxml.flightaware.com/soap/FlightXML2b"><SOAP-ENV:Body><FlightXML2b:FlightInfoStatusResults><FlightXML2b:FlightInfoStatusResult><FlightXML2b:next_offset>0</FlightXML2b:next_offset><FlightXML2b:flights><FlightXML2b:faFlightID>BAW697-1443681733-airline-0020</FlightXML2b:faFlightID
...


Hi,

Yes, nothing has changed at our end since 2012.

I had an email from support@flightaware Friday night saying “Our developers informed me that this issue should be corrected and that everything should be displaying properly for you.” ???

If there was nothing wrong at your end, how could this have been resolved? Regardless, it is still not working… Same authentication error is being received.

I’m not sure why support sent that email to you. It was probably a misunderstanding, since there have been no actual changes done specific to your issue. You can also verify that the following PHP example works fine (I realize that you are not using PHP, but this will demonstrate that the functionality works from your account).



<?php

$options = array(
                 'trace' => true,
                 'exceptions' => 0,
                 'login' => 'richardhardy',
                 'password' => 'xxxxxxxxxxxx',
                 );
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2b/wsdl', $options);

// get the weather.
$params = array("ident" => "BAW697", "offset" => 0, "howMany" => 15);
$result = $client->FlightInfoStatus($params);
print_r($result);

?>

I can confirm that this works with our credentials.

Surely the fact our software making the FlightXML call is getting a response from your servers is indicative that there isn’t a problem with our implementation. If we received no response this would be a different matter entirely. However, we are getting an Authentication error so either we are passing the Authorization string in the wrong format (although this hasn’t changed so I’m no sure why it would stop working suddenly) or there s a problem interpreting this at your end of things as the credentials work in both PHP and json requests.

Is there any way we can arrange any live testing of this with someone monitoring the request coming in to identify why it is failing and returning the reported error?

Are you able to do a network packet capture of the requests you are generating? That would allow you to verify the actual HTTP request headers match what you expect. (It is not easy for us to do network captures on our production environment and attempt to isolate an individual request, due to the volume of traffic that we receive and with the layers of proxying that strip originating IP addresses.) If possible, compare the contents of the “Authorization” header generated by the PHP example with what your application is generating. The content of that Authorization header should match exactly in those two cases.

Hi,

Thank you for all assistance with this matter. I can confirm that this has now been resolved.

While reviewing in detail the requests sent to and received from yourselves it was found that one line in our XML structure (the Authorization line) did not have the required CarriageReturn, Linefeed suffixed to it.

This however has been working for years without error so I would assume an update somewhere along the line has finally prevented this from working. The error we were getting back however was a bit misleading as normally we would expect this to return read Error in XML and not ‘Authorization error’.

Thank you once again for all your assistance.

Kind Regards

Chris