Jump to content
McKay Development

Recommended Posts

Posted (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 :

steamguard3.thumb.png.2a0524dd8f956e70b586cd9c7d057d9d.png

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 by demonix
Posted

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

Posted (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 by demonix
Posted

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.

Posted

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...