Anonymous Authentication

Overview

In order to make a request to an authenticated service (such as creating a flight plan), the user will need to be authenticated. The easiest way to accomplish this is using AirMap's Anonymous Authentication service.

The AirMap Anonymous User Authentication allows developer client applications to create an anonymous AirMap pilot user and retrieve a valid JSON Web Token for that user to interact directly with AirMap APIs.

Parameters

To get a valid JWT, you can query the Anonymous User API endpoint with the developer's Application API key and UserID for the user:

https://api.airmap.com/auth/v1/anonymous/token

NameDescription
user_idAny unique identifier from the developer for their user (UUID, username, email)

Example

Request an anonymous user JWT with your API Key and user identifier of choice. The response will contain a valid JWT.

## Request

curl -X "POST" "https://api.airmap.com/auth/v1/anonymous/token" \
    -H "X-API-Key: {YOUR API KEY}" \
    -d "user_id={UNIQUE IDENTIFIER}"
  
## Response

{
  "status": "success",
  "data": {
    "id_token": "JWT_TOKEN_HERE"
  }
}
AirMap.performAnonymousLogin(userId: "acme|123") { (result: Result<AirMapToken>) in
    switch result {
    
    case .error(let error):
        print(error)
    
    case .value(let token):
        print(token.authToken)
    }
}
String userId = "acme|123";

AirMap.performAnonymousLogin(userId, new AirMapCallback<Void>() {
    @Override
    public void onSuccess(Void response) {
        AirMapLog.d(TAG, "Token is: " + AirMap.getAuthToken());

        // Handle login
    }

    @Override
    public void onError(AirMapException e) {
        AirMapLog.e(TAG, e.getDetailedMessage(), e);

        // Handle error here
    }
});
var request = require('superagent');

request
  .post('https://api.airmap.com/auth/v1/anonymous/token')
  .send({
  "user_id": "{UNIQUE IDENTIFIER}"
})
  .set('X-API-Key', '{YOUR API KEY}')
  .redirects(0)
  .end(function(err, res){
    if (err || !res.ok) {
      console.log(err);
    } else {
      console.log(JSON.stringify(res.body));
    }
  });
import requests

def send_request():
    try:
        response = requests.post(
            url="https://api.airmap.com/auth/v1/anonymous/token",
            headers={
                "X-API-Key": "{YOUR API KEY}"
            },
            data={"user_id": "{UNIQUE IDENTIFIER}"}
        )
        print('Response HTTP Status Code: {status_code}'.format(
            status_code=response.status_code))
        print('Response HTTP Response Body: {content}'.format(
            content=response.content))
    except requests.exceptions.RequestException:
        print('HTTP Request failed')
require 'net/http'
require 'net/https'

def send_request
  begin
    uri = URI('https://api.airmap.com/auth/v1/anonymous/token')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    # Create Request
    req =  Net::HTTP::Delete.new(uri)
    # Add headers
    req.add_field "X-API-Key", "{YOUR API KEY}"
    req.body = "user_id={UNIQUE IDENTIFIER}"

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end

Updated 2 years ago

Anonymous Authentication


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.