API Authentication
The Loyalty.lt API supports multiple authentication methods designed for different integration scenarios. Choose the method that best fits your application’s architecture and security requirements.All authentication methods use HTTPS encryption and include rate limiting for security. All examples below use real endpoints that you can test.
Authentication Methods Overview
QR Code Authentication is the primary login method for Loyalty.lt, enabling secure cross-device authentication with real-time communication.
Method | Use Case | Security Level | Rate Limit |
---|---|---|---|
🔥 QR Code Auth | Primary: Desktop/Mobile | High | 1,000/hour |
Phone + OTP | Mobile app login | High | 500/hour |
API Credentials | Server integrations | High | 2,000/hour |
JWT Tokens | User sessions | Medium | 1,000/hour |
Partner Authentication | Partner management | High | 5,000/hour |
QR Code Authentication (Primary Method)
Best for: Desktop/web applications with mobile app authentication, cross-device login QR Code authentication is the primary authentication method for Loyalty.lt, providing secure login by scanning QR codes with the mobile app. This method offers enhanced security through device separation and real-time verification.How QR Authentication Works
1
Generate QR Session
Desktop/web app creates a unique QR code session with 5-minute expiration.
2
Display QR Code
QR code is displayed to the user on desktop/web interface.
3
Mobile Scan
Authenticated mobile user scans the QR code using the Loyalty.lt app.
4
User Confirmation
User confirms login on mobile device after reviewing session details.
5
Real-time Authentication
Desktop/web receives authentication tokens via Ably WebSocket connection.
Quick Start Example
Security Features
- Session Expiration: 5-minute timeout for enhanced security
- Device Separation: Authentication happens on separate trusted device
- Real-time Verification: Instant status updates via WebSocket
- User Authorization: Only authenticated mobile users can complete login
For complete QR authentication documentation with all endpoints, examples, and implementation guides, see the QR Code Authentication section.
Phone + OTP Authentication
Best for: Mobile applications, direct phone number verification Alternative authentication method using phone number and one-time password (OTP) verification.Basic Flow
1
Request OTP
Send OTP code to user’s phone number for authentication.
2
User Enters OTP
User receives and enters the 6-digit verification code.
3
Verify & Login
API verifies OTP and returns JWT tokens for session management.
Quick Example
API Credentials
Best for: E-commerce platforms, POS systems, server-to-server integrations API Credentials provide the highest level of security and are designed for backend integrations where you can safely store secrets.How API Credentials Work
- Generate credentials in the Partner Dashboard
- Store securely on your server (never in frontend code)
- Include headers in every API request
- Automatic validation by our API gateway
Getting API Credentials
1
Access Partner Dashboard
Visit partners.loyalty.lt and sign in to your account.
2
Navigate to API Settings
Go to Settings → API Credentials in your dashboard.
3
Generate New Credentials
Click Generate New API Key and securely store both the API Key and API Secret.
Using API Credentials
Include these headers in every request:X-API-Key
: Your public API keyX-API-Secret
: Your private API secretContent-Type
: Alwaysapplication/json
Security Features
Restrict API access to specific IP addresses for enhanced security.
JWT Tokens
Best for: Mobile apps, customer portals, user-specific operations JWT tokens provide session-based authentication for customer-facing features where users log in with their phone number and OTP.Phone + OTP Authentication Flow
The primary method for customer authentication:1
Request OTP
Send OTP code to customer’s phone:
2
Verify OTP & Login
Verify the OTP code and receive JWT token:Response:
3
Use JWT Token
Include the JWT token in subsequent requests:
QR Code Authentication
Alternative authentication method for desktop-to-mobile scenarios:1
Generate QR Session
2
Display QR Code
Show the QR code to the user and poll for status:
3
Mobile Scan & Confirm
User scans QR with mobile app and confirms login.
Token Management
Token Lifecycle:- Access Token: 1 hour lifetime
- Refresh Token: 30 days lifetime
- Auto-refresh: Seamless token renewal
Authentication Comparison
Feature | API Credentials | JWT Tokens |
---|---|---|
Use Case | Server backends | User sessions |
Storage | Server environment | Client app |
Expires | Never (unless revoked) | 1 hour (renewable) |
Rate Limit | 2,000/hour | 1,000/hour |
User Context | No | Yes (specific user) |
Security | Very High | Medium |
Environment-Specific Examples
Use for development and testing:Safe to test with any data - no impact on production.
Common Authentication Errors
Error Code | Status | Cause | Solution |
---|---|---|---|
AUTH_REQUIRED | 401 | Missing auth headers | Add X-API-Key and X-API-Secret |
INVALID_CREDENTIALS | 401 | Wrong API credentials | Verify key/secret in dashboard |
TOKEN_EXPIRED | 401 | JWT token expired | Use refresh token endpoint |
INSUFFICIENT_PERMISSIONS | 403 | Limited access rights | Check partner permissions |
RATE_LIMIT_EXCEEDED | 429 | Too many requests | Implement exponential backoff |
Best Practices
- Never expose credentials in frontend code or logs
- Use environment variables for credential storage
- Implement token refresh logic for JWT tokens
- Validate responses and handle errors gracefully
- Use HTTPS only for all API communications
Testing Authentication
Quick Test Endpoints
Test your authentication setup with these endpoints: API Credentials Test:Postman Collection
Download our Postman collection for easy API testing:Download Postman Collection
Pre-configured requests with authentication examples
Support
Test Endpoints
Interactive testing for all auth endpoints
Partner Dashboard
Manage credentials and view usage analytics
Authentication is handled automatically when using our official SDKs. The manual examples above are provided for custom integrations and debugging.