The OneZeroScraper requires a multi-step authentication process to handle Two-Factor Authentication (2FA). You can either provide a pre-existing otpLongTermToken or implement an otpCodeRetriever callback to handle the SMS code.
To use the callback method:
- Provide a
phoneNumber in international format (e.g., +972...). - Provide an
otpCodeRetriever function that returns the SMS code as a Promise<string>.
If you are performing the steps manually, you can call triggerTwoFactorAuth(phoneNumber) first, then getLongTermTwoFactorToken(otpCode) to obtain a long-term token.
const credentials = {
email: 'user@example.com',
password: 'your-password',
phoneNumber: '+972501234567',
otpCodeRetriever: async () => {
// Logic to retrieve the SMS code from your system/user
return '123456';
}
};
const scraper = new OneZeroScraper();
const loginResult = await scraper.login(credentials);