Overview

You can log in to smartCARS, but after logging in, you get an error like:

  • Failed to fetch airports
  • Failed to fetch bids
  • Failed to fetch PIREPs

Explanation

This generally happens when the smartCARS API is returning a 401 HTTP status code in all responses. This is the status code for "Unauthorized" and is only given by the smartCARS 3 API when the session provided is not valid.


smartCARS 3 uses a standard REST API authentication method known as "Bearer tokens". By default, PHP does not allow the passing of such Bearer tokens through the "Authorization header" when making HTTP requests. This behaviour can usually be changed through the .htaccess files that smartCARS 3 uses. The contents which are responsible for making the Authorization header useful in smartCARS are shown below:


RewriteEngine On
CGIPassAuth On
RewriteRule .* - [e=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


The first line enables the rewrite engine, which allows "rewriting" under certain conditions. CGIPassAuth is a condition that allows scripts to access the Authorization header, and the last line rewrites the Authorization header to a PHP server variable.


This code has been working for many communities that use smartCARS and there are very few conditions in which this does not work, which are listed below:

  • Your hosting server has not been configured for CGIPassAuth to be enabled, this is configured by the hosting provider alone. You may need to contact your host for this.
  • Your hosting configuration is not using Apache but is instead using nginx. You should follow step 2 of the Public API to configure your API for nginx installs.


Instructions

  1. If you are not hosted with TFDi Design, please contact your web host and ensure that CGIPassAuth is enabled on their server. If CGIPassAuth is not enabled on the host, smartCARS 3's API will not be compatible.
  2. If you are hosting with nginx, please ensure that Step 2 is followed, as previously mentioned.
  3. If you have tried the above, and you are still getting these error messages, please consider opening a ticket.