Skip to content

Authentication

LuxMart API uses token-based authentication. After successful login, you receive an access token that must be included in subsequent requests.

Authentication Flow

Standard Flow

  1. Register a user or store account
  2. Verify OTP sent to your email
  3. Login with credentials to receive an access token
  4. Use the token in the Authorization header for protected endpoints

Google OAuth Flow (Users Only)

  1. Initiate OAuth - Redirect user to Google OAuth consent screen
  2. User authorizes - User grants permissions
  3. Receive code - Google redirects back with authorization code
  4. Exchange code - Send code to /v1/accounts/login/google/ to receive access token
  5. Use the token - Use the token in the Authorization header for protected endpoints

See Login with Google OAuth for detailed documentation.

Using the Token

Include the token in the Authorization header with the format:

Authorization: Token <your_access_token>

Example Request

curl -X GET "https://api.luxmart.site/v1/accounts/user/site/" \
  -H "Authorization: Token your_access_token_here"

Token Expiration

Tokens expire after 30 days of inactivity. You'll need to login again to get a new token.

Role-Based Access

Different endpoints require different user roles:

  • User (Role: "1"): Regular customer access
  • Store (Role: "3"): Store owner access
  • Admin (Role: "2"): Administrator access

Some endpoints are restricted to specific roles. Attempting to access restricted endpoints will return a 403 Forbidden error.

Error Responses

Missing Token

{
  "error": "Missing token on header!"
}

Status Code: 401 Unauthorized

Invalid Token

{
  "error": "token is not active!"
}

Status Code: 401 Unauthorized

Access Denied

{
  "error": "Access denied!"
}

Status Code: 403 Forbidden

Public Endpoints

The following endpoints do not require authentication:

  • User/Store Registration
  • Login endpoints (including Google OAuth)
  • OTP verification
  • Password reset
  • Get all stores (public)
  • Get all categories
  • Get all brands
  • Get site products (public)
  • Get currencies (public)
  • Get countries and cities
  • Create contact form
  • Create email subscription