For platform integrations that need to onboard merchants programmatically, use loginAndRetrieveCredentials. This method performs the complete authentication flow:
Sign in — Authenticate user with email/password
Get merchant — Retrieve associated merchant details
Register OAuth — Create OAuth credentials for the merchant (idempotent)
Authenticate — Get access tokens using the new credentials
Important: This method requires an Admin Key and is intended for platform-level operations, not end-user authentication.
Code
import { SaligPay } from "saligpay-node";const saligpay = new SaligPay({ adminKey: process.env.SALIGPAY_ADMIN_KEY!, env: "sandbox",});// Full login flow for a merchantconst result = await saligpay.auth.loginAndRetrieveCredentials( "merchant@example.com", "merchant-password",);// Result contains everything needed for subsequent API callsconsole.log("User:", result.user);console.log("Merchant:", result.merchant);console.log("OAuth Credentials:", result.credentials);console.log("Access Token:", result.tokens.accessToken);