Skip to content

Commit

Permalink
Add extra header Authorization for API calls, improve documentation…
Browse files Browse the repository at this point in the history
… for API keys
  • Loading branch information
fboes committed Nov 12, 2019
1 parent 9eb5fd6 commit 50815e2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change log
==========

1.4.0
-----

* 🎁 Add extra header `Authorization` for API calls, improve documentation for API keys

1.3.1
-----

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ This project was built with Microsoft Visual Studio 2017.

Dependencies:

1. [Curl](https://curl.haxx.se/): Install via `vcpkg install curl curl:x64-windows`.
1. [WxWidgets](https://www.wxwidgets.org/): Install via `vcpkg install wxwidgets wxwidgets:x64-windows`.
1. [Curl](https://curl.haxx.se/): Install via `vcpkg install curl curl:x64-windows`
1. [WxWidgets](https://www.wxwidgets.org/): Install via `vcpkg install wxwidgets wxwidgets:x64-windows`

Remember to integrate via `vcpkg integrate install`.

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Installation

1. Download the latest release ZIP from https://github.com/fboes/aerofly-wettergeraet/releases/latest.
2. Unpack the ZIP file to some sensible location, e.g. `C:\Program Files\aerofly-wettergeraet-x64\`.
3. You will also need an API key for the [AVWX REST API](http://avwx.rest/), which can be acquired at https://account.avwx.rest
3. Create a shortcut on your desktop by right-clicking `aerofly-wettergeraet-desktop.exe` > "Send to" > "Desktop (Create shortcut)".
You might want to re-label the shortcut to "Aerofly Wettergerät".
3. Supply your API key, see [the configuration guide](docs/configuration.md)
3. Start the desktop application by clicking on the desktop link.

In case you want to use this application on a different operation system, consider [building your own executable from this project](CONTRIBUTING.md).
Expand Down Expand Up @@ -65,7 +67,7 @@ HTTP services

This tool is compatible with the following METAR services:

* [AVWX](http://avwx.rest/): This is the default HTTP service.
* [AVWX](http://avwx.rest/): This is the default HTTP service. You will need to get an API key to use this service.
* [CheckWX](https://www.checkwx.com/): You will need to get an API key to use this service.

You may also try any other HTTP service which offers METAR information as raw text or JSON. See the [configuration guide on how to set different METAR services](docs/configuration.md).
Expand Down
49 changes: 18 additions & 31 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,22 @@ For more information about command line options, call the command line variant o

There is also a [source code documentation on command-line parameters](https://github.com/fboes/aerofly-wettergeraet/blob/master/src/WettergeraetLib/Argumentor.cpp#L65) applicable for the command-line as well as the desktop variant of this tool.

To append parameters to the desktop application, right-click your desktop icon, select "Properties" and append the parameter(s) to the shortcut's target.
Supplying parameters to the desktop application
-----------------------------------------------

![](modify-shortcut.png)

Register file associations
--------------------------

You may register `.mcf` and `.rwx` file types with the desktop version of the <i>Aerofly Wettergerät</i> by double-clicking these files. This will open up the application with the corresponding file loaded.

HTTP services
-------------

This tool has been tested with multiple METAR services. To change the METAR service for the command line variant `aerofly-wettergeraet.exe` append additional parameters:

```batch
: Supply METAR manually
aerofly-wettergeraet.exe --metar ?
: AVWX - this is the default HTTP service
aerofly-wettergeraet.exe --url "http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache"
To supply parameters to the desktop application, right-click your desktop icon, select "Properties" and append the parameter(s) to the shortcut's target, like `--PARAMETER_NAME "PARAMETER_VALUE"`, e.g. `--apikey "ABCDEF"` to supply an API key.

: CheckWX - you will need to get an API key
aerofly-wettergeraet.exe --url "https://api.checkwx.com/metar/XXXX/decoded" --apikey "INSERT API KEY HERE"
```
![](modify-shortcut.png)

To change the METAR service for the desktop variant `aerofly-wettergeraet-desktop.exe` change the target of your desktop shortcut:
These parameters are available:

```batch
: AVWX - this is the default HTTP service
aerofly-wettergeraet-desktop.exe --url "http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache"
: CheckWX - you will need to get an API key
aerofly-wettergeraet-desktop.exe --url "https://api.checkwx.com/metar/XXXX/decoded" --apikey "INSERT API KEY HERE"
```
| Parameter | Example value | Description |
| ------------- | ----------------------- | ------------------------------------------ |
| `--file` | `C:\Users\...\main.mcf` | Absolute file location of your `main.mcf`. |
| `--url` | `http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache` | Fetch response via HTTP from this URL. If URL contains `XXXX` this will be replaced by the ICAO airport code. |
| `--apikey` | `12345abcd` | Sent HTTP header `X-API-Key` / `Authorization` set to this value for all HTTP API calls. |
| `--response` | `raw` | How to interpret HTTP response. Set this to `raw` if the response is plain text. Set this to `json` if the response is JSON object. |
| `--hours` | `-8` | Offset time read from METAR code by this value, given in hours. |

Change default values
---------------------
Expand All @@ -51,7 +33,7 @@ These variables are available:
| -------------------- | ----------------------- | ------------------------------------------ |
| `AEROFLYWX_FILE` | `C:\Users\...\main.mcf` | Absolute file location of your `main.mcf`. |
| `AEROFLYWX_URL` | `http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache` | Fetch response via HTTP from this URL. If URL contains `XXXX` this will be replaced by the ICAO airport code. |
| `AEROFLYWX_APIKEY` | `12345abcd` | Sent HTTP header `X-API-Key` set to this value for all HTTP API calls. |
| `AEROFLYWX_APIKEY` | `12345abcd` | Sent HTTP header `X-API-Key` / `Authorization` set to this value for all HTTP API calls. |
| `AEROFLYWX_RESPONSE` | `raw` | How to interpret HTTP response. Set this to `raw` if the response is plain text. Set this to `json` if the response is JSON object. |
| `AEROFLYWX_HOURS` | `-8` | Offset time read from METAR code by this value, given in hours. |

Expand All @@ -76,6 +58,11 @@ For Mac OSX / Linux open up a terminal and enter the following lines:
VARIABLE="VALUE"
```

Register file associations
--------------------------

You may register `.mcf` and `.rwx` file types with the desktop version of the <i>Aerofly Wettergerät</i> by double-clicking these files. This will open up the application with the corresponding file loaded.

---

Return to [table of contents](README.md).
2 changes: 1 addition & 1 deletion src/WettergeraetLib/Argumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <sstream>
#include <iterator>

const char* Argumentor::APP_VERSION = "1.3.1";
const char* Argumentor::APP_VERSION = "1.4.0";
#if _WIN64
const char* Argumentor::APP_TARGET = "64-bit";
#else
Expand Down
2 changes: 2 additions & 0 deletions src/WettergeraetLib/FetchUrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ std::string FetchUrl::fetch(std::string url, unsigned short fetchMode, std::stri
if (apiKey != "") {
apiKey = "X-API-Key: " + apiKey;
httpHeaders = curl_slist_append(httpHeaders, apiKey.c_str());
apiKey = "Authorization: " + apiKey;
httpHeaders = curl_slist_append(httpHeaders, apiKey.c_str());
}

curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
Expand Down

0 comments on commit 50815e2

Please sign in to comment.