Authentication & Account Management

JWT authentication flows, token lifecycle, session management, guest users, person management, and health checks.

Authentication & Account Management

Overview

The Nomad Media API uses JWT Bearer tokens for authentication. All authenticated endpoints require a valid access token in the Authorization header:

Authorization: Bearer <your-access-token>

Access tokens have a limited lifetime (indicated by ExpirationSeconds in the login response). Use the refresh token to obtain a new access token before the current one expires.

Base Routes

APIRoute PrefixDescription
Core/accountLogin, registration, password management, email verification
Portal/accountEmail availability checks, profile updates, guest user management
Admin/admin/user-sessionSession monitoring and status management
Core/pingHealth checks and token validation
Core/personPerson management for facial recognition

Authentication Flow

Standard Registration & Login

1. POST /account/register          - Create a new account
2. POST /account/verify            - Verify email with the code sent to user
3. POST /account/login             - Authenticate and receive JWT token
4. Use Bearer token for all authenticated requests
5. POST /account/ping              - Keep session alive (periodic)
6. POST /account/refresh-token     - Get new token before expiration
7. POST /account/logout            - End session

Guest User Flow

1. POST /account/invite-user       - Invite guests with content access (authenticated user)
2. POST /account/register-guest    - Guest completes registration via invitation
3. POST /account/login             - Guest logs in with their credentials

Password Reset Flow

1. POST /account/forgot-password   - Request a password reset code
2. POST /account/reset-password    - Submit the code and set a new password

Account Statuses

When an account is in a non-standard state, the API returns a LoginStatus value indicating what action is needed:

StatusValueDescription
TwoFactorSetupRequired1User must set up two-factor authentication
TwoFactorCodeRequired2User must provide a 2FA code
IsDisabled3Account is disabled by an administrator
IsPendingEmailConfirmation4Email verification is required
IsPendingNewAccountSignup5Account registration is incomplete
IsPendingAccountMigrationSignup6Account migration is required
IsPendingNewPassword7A new password must be set
IsExpired8Account has expired
IsPendingInvitation9Guest invitation has not been completed

Session Management

Keeping Sessions Alive

Use POST /account/ping periodically to keep a session active. The response includes a PingStatus:

StatusValueAction Required
Normal1Session is healthy, no action needed
ChatDisabled2Chat functionality has been restricted
AccountExpired3Redirect user to login, account has expired
SessionDeactivated4Session was replaced by a newer login

Single-Session Enforcement

When enabled, only one active session per user is allowed. If a user logs in from a new device or browser, the previous session is replaced and will return SessionDeactivated on the next ping.

Session Status Management (Admin)

Administrators can manage user sessions via the Admin API:

  • GET /admin/user-session/{id} - View session details
  • POST /admin/user-session - Change session status (e.g., kick user, restrict chat)

Available session statuses:

StatusValueDescription
Normal1Active session with full access
ChatDisabled2Chat functionality restricted
SessionReplaced3Replaced by newer login
Deactivated4Deactivated by administrator
SharedAccess5Guest with shared content access
PendingInvite6Pending guest invitation
Expired7Session expired
DeletedInvite8Invitation was revoked

Token Lifecycle

PropertyDescription
TokenJWT access token for API requests. Include in Authorization: Bearer <token> header.
RefreshTokenUse with POST /account/refresh-token to obtain a new access token.
ExpirationSecondsDuration in seconds until the access token expires.

Guest User Management

Inviting Guests

Use POST /account/invite-user to invite users as guests with access to specific content:

  • Provide an array of email addresses and the ContentDefinitionId for the content to share
  • Each invited user receives an email with registration instructions
  • New guest accounts are created with PendingInvitation status

Removing Guests

Use POST /account/remove-user to revoke a guest's content access:

  • Specify the user by UserId or Emails along with the ContentId
  • The user's sessions are terminated
  • If the user has no remaining content access, their account may be expired or removed

Live Channel Sessions (Portal)

GET /user-session/{id} returns the users associated with a live channel:

  • Items: Currently online users with active sessions
  • RelatedItems: Offline shared-access users (with " (offline)" suffix) and users with pending invitations
  • Currently only supports live channel content definitions

Person Management

The person API manages person entities for facial recognition matching:

EndpointMethodDescription
/personPOSTCreate a new person (name must be unique)
/person/{id}GETRetrieve person details and face match counts
/person/{id}PUTUpdate a person (currently stubbed)
/person/{id}DELETEPermanently delete a person
/person/{id}/{faceMatchType}GETGet faces by match type (currently stubbed)

Face Match Types

TypeValueDescription
Automatch1Automatically matched by AI with high confidence
ProbableMatch2Probable match requiring manual review
NotMatch3Reviewed and determined to not match
ConfirmedMatch4Manually confirmed as a match
Blurry5Too blurry for reliable matching

Health Checks

EndpointAuth RequiredDescription
GET /pingNoReturns "Pong" to confirm API is running
GET /ping?includeHeaders=trueNoReturns all request headers (debugging)
GET /ping/authYesReturns "Pong Auth" to validate Bearer token

Common Error Responses

Status CodeDescription
400Bad Request - Missing or invalid request parameters
401Unauthorized - Missing or invalid Bearer token
403Forbidden - Account is disabled, expired, or pending
404Not Found - Resource not found or authentication failed