Authentication
How a program gets a token with an API key, how to use and refresh it, and the token for the live socket and driver apps.
Every API request carries an access token in the Authorization header. How you get the token depends on what is calling.
| Who calls | How it signs in |
|---|---|
| Your server (an ERP sync, a nightly job) | An API key: a client id and secret, OAuth 2 client credentials |
| A web or mobile app where a person signs in | OAuth 2 authorization code with PKCE, as the console does |
| A driver app | A driver's app code, traded for a driver token |
API keys (server to server)
An API key is a machine account for your company: it is not a person, it has no password, and it holds only the permissions you choose for it (for example fleet:read and money:read for an accounting sync). Make one per system, so you can switch any of them off on its own.
Making one: your company's owner opens API keys in the console menu (under Manage) and clicks New key:
- Name it after the system that will use it, for example ERP sync.
- Tick what it may do. You can give a key only permissions you hold yourself.
- Copy the client id and client secret. The secret is shown once; LemursEye cannot show it again.
Keep the secret on your server only; never put it in a browser or a phone app. On the same page you can change a key's permissions, issue a new secret (the old one stops working at once), disable a key, or delete it. If a secret leaks, issue a new one or delete the key straight away.
A key can never invite people, change roles, or make other keys (users:write, roles:manage and integrations:manage are never granted to a key), and it never has staff powers. A company can have up to 20 keys. Tokens already issued stay valid until they expire, at most about five minutes after a change.
1. Get a token
curl -s https://lemurseye.com/auth/realms/eagleseye/protocol/openid-connect/token \
-d grant_type=client_credentials \
-d client_id=YOUR_CLIENT_ID \
-d client_secret=YOUR_CLIENT_SECRET
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIi...",
"expires_in": 300,
"token_type": "Bearer",
"scope": "profile email"
}
2. Call the API
curl -s https://lemurseye.com/api/v1/vehicles \
-H "Authorization: Bearer $TOKEN"
3. Renew before it expires
The token is valid for expires_in seconds (about five minutes). Cache it, and ask for a new one shortly before it expires, or when a call answers 401. A client-credentials token has no refresh token: you simply ask again.
import time, requests
TOKEN_URL = "https://lemurseye.com/auth/realms/eagleseye/protocol/openid-connect/token"
_cache = {"token": None, "until": 0}
def token():
if time.time() > _cache["until"] - 30:
r = requests.post(TOKEN_URL, data={
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
})
r.raise_for_status()
body = r.json()
_cache.update(token=body["access_token"], until=time.time() + body["expires_in"])
return _cache["token"]
vehicles = requests.get("https://lemurseye.com/api/v1/vehicles",
headers={"Authorization": f"Bearer {token()}"}).json()
Apps where a person signs in
A web or mobile app that acts as a person (with their roles) uses the authorization code flow with PKCE against the same realm:
| Setting | Value |
|---|---|
| Authorization endpoint | https://lemurseye.com/auth/realms/eagleseye/protocol/openid-connect/auth |
| Token endpoint | https://lemurseye.com/auth/realms/eagleseye/protocol/openid-connect/token |
| Scopes | openid profile email |
The app needs its own client registered with your redirect address: ask us for one. Signing in with a username and password straight against the token endpoint (the password grant) is switched off: it would let any app collect people's passwords.
Check who you are
GET /api/v1/me returns who the token belongs to, its company and permissions. It is the quickest way to test a token. For an API key, roles is empty and permissions lists exactly what the key was given.
curl -s https://lemurseye.com/api/v1/me -H "Authorization: Bearer $TOKEN"
{
"userId": "4b1f0c5e-8a77-4a2b-9c1e-2f6a0a9d3e11",
"username": "service-account-int-nile-logistics-erp-sync",
"name": null,
"email": null,
"tenantId": "nile-logistics",
"roles": [],
"permissions": ["fleet:read", "money:read", "reports:read"],
"platformAdmin": false,
"units": "metric",
"currency": "USD",
"timezone": "Africa/Cairo",
"impersonating": null
}
The live socket
Browsers cannot set headers on a WebSocket, so for that one endpoint the token goes in the address:
wss://lemurseye.com/ws/live?access_token=ACCESS_TOKEN
When the token expires the server closes the connection; reconnect with a fresh token. See Live socket.
Driver tokens
The driver endpoints under /api/v1/driver/ (the driver's own trips, confirming stops) do not use the bearer token. A driver app trades the driver's app code for a session token and sends it as X-Driver-Token:
curl -s https://lemurseye.com/api/v1/driver/session \
-H "Content-Type: application/json" \
-d '{"code": "K7M2-9QX4", "device": "Samsung A54"}'
{ "token": "pQ3v...Xz8", "driverName": "Mohamed Fathy", "company": "Nile Logistics" }
curl -s "https://lemurseye.com/api/v1/driver/trips?from=2026-10-27T00:00:00%2B02:00&to=2026-10-28T00:00:00%2B02:00" \
-H "X-Driver-Token: pQ3v...Xz8"
The token lasts until the driver signs out or the manager makes a new app code. Wrong codes are rate-limited (429 after several attempts).