Skip to Content
HomeLink Hub

Authentication

How clients get, send, refresh and lose access tokens, and how social sign-in and KYC fit in.

The API uses JSON Web Tokens. Signing in returns two tokens:

TokenUsed forLifetime
Access tokenSent with every protected requestJWT_ACCESS_EXPIRY on the server. 15 minutes if unset.
Refresh tokenGetting a new access tokenJWT_REFRESH_EXPIRY on the server. 7 days if unset.

Sending the token

GET /api/v1/user/profile
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

On every protected request the server verifies the token and loads the user. The token carries the user's id, email, role and a session id.

Two places accept the token another way:

  • The server-sent events stream (GET /api/v1/stream/events) also accepts ?token=<access token>, because a browser EventSource cannot set headers.
  • The Socket.IO handshake takes it as auth.token (or query.token), without the Bearer prefix.

Getting tokens

Sign up

POST /auth/signup creates an unverified account and emails a verification link (web) or a 4-digit code valid for 15 minutes (when the body has isMobile: true). No tokens are returned. The role defaults to TENANT; ADMIN cannot be chosen.

Verify the email

The verification page calls GET /auth/verify-email?token=.... Mobile apps send the code to POST /auth/verify-email-otp. POST /auth/resend-verification sends a new link or code and invalidates the old one.

Sign in

POST /auth/signin with email and password returns accessToken, refreshToken and a short user object. Unverified and deactivated accounts are refused.

Google and Apple

FlowEndpoints
Google on the webGET /auth/google returns data.authUrl. Send the browser there. Google redirects back to the web app, which forwards the code to GET /auth/google/callback. That returns the same body as sign-in.
Google on mobileThe app signs in with the Google SDK and sends the ID token to POST /auth/google/native.
Apple on iOSThe app sends the identity token (and, the first time, the user's name) to POST /auth/apple/native.

Social sign-in creates the account on first use, already email-verified and without a password. An existing account with the same email is linked instead.

Refreshing

When a request fails with 401 Token has expired, call POST /auth/refresh-token with the refresh token. It returns a new access token; the refresh token itself is not rotated.

One refresh token per account

The account stores a single refresh token. Signing in on another device replaces it, so the first device's refresh token stops working and that device must sign in again.

Signing out

ActionEndpointEffect
Sign out this devicePOST /auth/signoutClears the refresh token and the session. Always answers 200.
Sign out everywherePOST /user/logout-all-devicesClears the refresh token and every session.
Change passwordPOST /user/change-passwordReplaces the password.
Reset passwordPOST /auth/forgot-password, then POST /auth/reset-passwordReplaces the password and clears the refresh token.

Access tokens are not revoked

None of these actions invalidates access tokens that were already issued. They keep working until they expire. The server also does not re-check whether the account is still active on each request, so a deactivated or deleted account's access token works until it expires. Keep JWT_ACCESS_EXPIRY short.

Sessions and two-factor

Each sign-in records a session (device, browser, location from the IP); the 10 most recent are kept and listed by GET /user/active-sessions. A sign-in from a new device sends a "New Login Detected" notification.

POST /user/enable-2fa and POST /user/disable-2fa only store a preference today. Sign-in does not ask for a second factor.

KYC

Agents and landlords must be KYC-verified to create listings.

EndpointPurpose
GET /auth/kyc/statusThe current status and which step is next
POST /auth/kyc/verifyLook up a NIN, driver's licence or CAC number. Only a NIN whose record matches the account's name verifies the account.
POST /auth/kyc/ninThe first step of a two-step NIN flow. The second step (liveness) does not exist yet, so use /auth/kyc/verify instead.

Errors you will see

StatusMessageCause
401Authentication required. Please provide a valid token.No Authorization header
401Token has expiredRefresh and retry
401Invalid tokenMalformed, or signed with another secret
401User not foundThe account no longer exists
403Access denied. This action requires one of the following roles: ...Wrong role for the endpoint

On this page