Skip to content

Connect an app to a pilot

Apps a pilot uses in the field, such as a ground station or a flight logger, connect to AYNA as that pilot. The pilot (or an admin) approves the app in AYNA and the app receives its own API key. No password is typed into the app.

Changes the app makes are recorded under the pilot’s name.

There are two ways to pair. Offer whichever suits your app; both give the same credentials.

Access code Device login
Who starts it The pilot, in AYNA The app
What the pilot does Types a short code into the app Opens a link, signs in, approves
Good for Apps with a keyboard Apps on a tablet, a controller or a headless device
Code lifetime 5 minutes, single use 10 minutes

In AYNA, open Pilots, select the pilot and find App Access Codes. Choose Generate Access Code. AYNA shows a code like KPX-482, valid for 5 minutes and usable once.

The pilot types the code into your app, and the app sends it to AYNA:

Terminal window
curl -X POST https://app.ayna.com/api/v1/auth/redeem-code \
-H "Content-Type: application/json" \
-d '{
"code": "KPX-482",
"device_info": {"app": "FieldLog", "version": "2.4.0", "platform": "android"}
}'

device_info is optional. Send your app’s name and version so the connection can be traced back to it.

{
"success": true,
"data": {
"api_key": "ak_9f2c...",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"token_type": "Bearer",
"expires_in": 3600,
"pilot_id": "5b0d...",
"pilot_name": "Jane Doe",
"organization_id": "c41e...",
"organization_name": "Skyline Aerial",
"subscription_tier": "professional",
"warning": "Store this API key securely. It will not be shown again!"
}
}

The api_key is shown only this once. Keep it in the device’s secure storage. Use it, or the access token, as the bearer token from now on.

Terminal window
curl -X POST https://app.ayna.com/api/v1/auth/device \
-H "Content-Type: application/json" \
-d '{"device_info": {"app": "FieldLog", "version": "2.4.0"}}'
{
"success": true,
"data": {
"user_code": "WDJ-937",
"device_code": "Gm1b7x...",
"verification_uri": "https://app.ayna.com/link/",
"verification_uri_complete": "https://app.ayna.com/link/?code=WDJ-937",
"expires_in": 600,
"interval": 5
}
}

Show the user_code and the verification_uri, or a QR code of verification_uri_complete. The pilot opens the link, signs in to AYNA, picks which pilot the app is for and chooses Authorize (or Deny).

Every interval seconds, ask whether the pilot has answered. Keep the device_code private: it is what claims the credentials.

Terminal window
curl -X POST https://app.ayna.com/api/v1/auth/device/token \
-H "Content-Type: application/json" \
-d '{"device_code": "Gm1b7x..."}'
Response Meaning What to do
200, "status": "authorized" The pilot approved Store the credentials. Same fields as the access code response.
200, "success": false, "error_code": "AUTHORIZATION_PENDING" Not answered yet Wait interval seconds and poll again
403 The pilot chose Deny Stop and tell the user
410 The 10 minutes ran out Start again from step 1
400 Unknown device_code Start again from step 1

The credentials are returned on the first successful poll only.

On the pilot’s page in AYNA, App Access Codes lists every code with the start of the key it issued. Choose Revoke on the app’s row. Its key stops working at once, and the pilot needs a new code or device login to connect it again. Device logins appear in the same list.

A paired app’s key works across your organization’s API, not only that pilot’s records, and writes are recorded as the pilot. Pair only apps you trust with your organization’s data.