demonix Posted March 28, 2020 Report Posted March 28, 2020 (edited) Hello everyone, before i make this topic, i already search and read some of the topic in this forum/issue in github, but i still dont understand what should i do, or maybe i'm doing it wrong. i'm trying to make an API login in nodejs for user (not bot) and input steamguard(one time/at first time), but i want to make it separately. for example : 1. user input username and password in form -> next/submit 2. user input steamguard in form 3. after that user will keep autologin. i've tried this : router.route('/login').get((req, res) => { var client = new SteamUser({ autoRelogin: true, promptSteamGuardCode: false }); client.logOn({ "accountName": config.accountName, "password": config.password }) }) and now i got this : router.route('/verify').get((req, res) => { var client = new SteamUser({ autoRelogin: true, promptSteamGuardCode: false }); client.logOn({ "accountName": config.accountName, "password": config.password, "twoFactorCode": "GGVGD", ////////////// How can I input this code separately in other form? "rememberPassword": true }) client.on('loggedOn', function (details) { console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID()); client.setPersona(SteamUser.EPersonaState.Online); client.gamesPlayed(440); }); }) but i dont understand how can user properly input steamguard separately after they input username and password, is what i'm doing already correct? forgive me if my topic is duplicate or if its a stupid questions. thanks Edited March 28, 2020 by demonix Quote
Dr. McKay Posted March 29, 2020 Report Posted March 29, 2020 You should use the steamGuard event rather than calling logOn multiple times. Quote
demonix Posted March 30, 2020 Author Report Posted March 30, 2020 thank you dr Mckay for your reply, this is still new for me, so i still dont know where to start, best regards, thanks Quote
demonix Posted March 30, 2020 Author Report Posted March 30, 2020 Hello, Dr McKay is this a correct way to do this ? var options = { promptSteamGuardCode: false, singleSentryfile: false, autoRelogin: true, dataDirectory: null, } var client = new SteamUser(options); router.route('/login').get((req, res) => { client.logOn({ "accountName": config.accountName, "password": config.password }) client.on('error', function (err) { switch (err.eresult) { case 5: log('error: invalid password'); case 84: log('error: rate limit exceeded'); case 6: log('error: logged in elsewhere'); default: log('error: ' + err.eresult); } stopClient(steamUsername); }); function stopClient(steamUsername) { if (typeof activeClient !== 'undefined' && activeClient) { //await activeBots[steamUsername].logOff(); // logOff is not async function? activeClient.logOff(); // logout, but if the bot ran into an error its not logged in delete activeClient; // seems to work, but not if it ran into an error log('client stopped', steamUsername); } } }) router.route('/verifycode').get((req, res) => { client.on('steamGuard', function(domain, callback) { console.log("Steam Guard code needed from email ending in " + domain); // var code = getCodeSomehow(); var code = "55X4B"; callback(code); }); }) router.route('/logout').get((req, res) => { SteamUser.logOff(); }) best regards, thanks Quote
Dr. McKay Posted March 30, 2020 Report Posted March 30, 2020 No, you probably want to put all your event handlers outside of your HTTP routes, and store the steamGuard callback in some global variable, so you can call it from your /verifycode route. Quote
demonix Posted March 31, 2020 Author Report Posted March 31, 2020 (edited) thank you for your reply dr McKay, so i need to put all my event outside the api? something like this example : var options = { promptSteamGuardCode: false, singleSentryfile: false, autoRelogin: true, dataDirectory: null, } var client = new SteamUser(options); client.on('error', function (err) { switch (err.eresult) { case 5: log('error: invalid password'); case 84: log('error: rate limit exceeded'); case 6: log('error: logged in elsewhere'); default: log('error: ' + err.eresult); } stopClient(steamUsername); }); function stopClient(steamUsername) { if (typeof activeClient !== 'undefined' && activeClient) { //await activeBots[steamUsername].logOff(); // logOff is not async function? activeClient.logOff(); // logout, but if the bot ran into an error its not logged in delete activeClient; // seems to work, but not if it ran into an error log('client stopped', steamUsername); } } router.route('/login').get((req, res) => { client.logOn({ "accountName": config.accountName, "password": config.password }) }) router.route('/verifycode').get((req, res) => { client.on('steamGuard', function(domain, callback) { console.log("Steam Guard code needed from email ending in " + domain); // var code = getCodeSomehow(); var code = "DVWQ4"; var callback = callback(code); res.status(200).json({ success: true, callback }) }); }) if i'm wrong again, could you please explained it in more detail? or is there any exact example that i can take a look? so sorry, because this is still new for me, so its still confusing how it really works. best regards, thanks Edited March 31, 2020 by demonix Quote
Dr. McKay Posted March 31, 2020 Report Posted March 31, 2020 I'm confused; are you planning to receive account credentials from the remote client that's invoking your HTTP endpoints? If not, then there's no point in having a /verifycode route; you should just handle the steamGuard event automatically. Quote
demonix Posted April 2, 2020 Author Report Posted April 2, 2020 hello Dr Mckay, thank you for your reply, i'm currently making an apps using reactnative that want to connect to steam by calling an api from the server (ex: the api is '/login') and that after i call that api, it will asking for the steam guard. so going back to reactnative and input the steamguard code and then calling another api from the server (ex: 'verifycode') is this possible? i just want to make sure that the one who use the apps have steam account. best regards, thank you Quote
Dr. McKay Posted April 3, 2020 Report Posted April 3, 2020 Yes, it's possible. You should probably seek help at stackoverflow.com; I'm not here to teach you JavaScript. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.