I'm using steam-user in a project where I can't get a Steam Guard code from a user through stdin. I'm using the following code, but it's inconsistent:
this.steamUser.logOn({ accountName: username, password: password, twoFactorCode: twoFactorCode });
this.steamUser.on('steamGuard', (_domain, callback) => {
callback(twoFactorCode);
});
this.steamUser.on('loggedOn', () => {
this.steamUser.getEncryptedAppTicket(1818750, async (err, appTicket) => {
if (err) {
throw new Error(err);
}
const data = await this.info(appTicket.toString('hex'));
this.accessToken = data.token;
});
});
resolve(this);
The above code works occasionally, but in the few times that it does work, nothing in the .getEncryptedAppTicket() block is executed. What am I doing wrong?