Authentication

The Lightyshare API uses token-based authentication to secure all API requests.

API Tokens

All API requests require authentication using an API token. You can obtain your API token from your Lightyshare dashboard. Include your API token in the Authorization header:
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     https://lightyshare.com/api/token-secured/rental/123

Using Query Parameter (Legacy)

For backward compatibility, you can also pass the token as a query parameter:
curl "https://lightyshare.com/api/token-secured/rental/123?token=YOUR_API_TOKEN"

Token Security

  • Keep your token secure: Never expose your API token in client-side code or public repositories
  • Token rotation: Regularly rotate your API tokens for enhanced security
  • Scope: Each token is tied to a specific user account and has access to that user’s resources only

Error Responses

Invalid Token (401 Unauthorized)

{
  "error": "Invalid or missing token"
}

Access Denied (403 Forbidden)

{
  "error": "Access denied to this resource"
}

Best Practices

  1. Use environment variables to store your API tokens
  2. Implement proper error handling for authentication failures
  3. Use HTTPS for all API requests
  4. Monitor token usage through your dashboard