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

FieldTypeDescription
tokenstringJWT for subsequent requests
user.idstringInternal user ID
user.emailstringAccount email
user.namestringDisplay name
user.rolestringAlways "MERCHANT"
merchant.idstringInternal merchant ID
merchant.sellerIdstringMerchant code (e.g. M001)
merchant.sellerNamestringStore name
merchant.billingModestringPREPAID or POSTPAID
merchant.walletBalancestringCurrent balance in KWD
merchant.scheduledDeliveryEnabledbooleanWhether 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;
  }
}