JWT authentication for mobile app integrations.
flasho.auth
flasho.auth
JWT authentication is intended for mobile app integrations. If you are building a server-side or website integration, use an API key instead.
login()
Log in with your Flasho dashboard email and password. The SDK stores the returned JWT automatically — all subsequent calls use it without any extra setup.
const flasho = new FlashoClient({ token: 'placeholder' });
const result = await flasho.auth.login({
email: '[email protected]',
password: 'your-password',
});
console.log(result.token); // eyJ...
console.log(result.merchant.sellerName); // "My Restaurant"
console.log(result.merchant.billingMode); // "PREPAID"
console.log(result.merchant.walletBalance); // "10.000"
// No need to set anything — the SDK already switched to this token
const data = await flasho.account.bootstrap();Response fields
| Field | Type | Description |
|---|---|---|
token | string | JWT for subsequent requests |
user.id | string | Internal user ID |
user.email | string | Account email |
user.name | string | Display name |
user.role | string | Always "MERCHANT" |
merchant.id | string | Internal merchant ID |
merchant.sellerId | string | Merchant code (e.g. M001) |
merchant.sellerName | string | Store name |
merchant.billingMode | string | PREPAID or POSTPAID |
merchant.walletBalance | string | Current balance in KWD |
merchant.scheduledDeliveryEnabled | boolean | Whether scheduled delivery is on |
⚠️ Token expiry
JWTs expire. In a mobile app, store the token securely and call login() again when you receive a 401 response.
import { FlashoApiError } from 'flasho-merchant-sdk';
async function safeCreate(flasho: FlashoClient, request: CreateDeliveryRequest) {
try {
return await flasho.deliveries.create(request);
} catch (err) {
if (err instanceof FlashoApiError && err.isUnauthorized) {
// Token expired — re-login and retry
await flasho.auth.login({ email, password });
return await flasho.deliveries.create(request);
}
throw err;
}
}