Jump to content
McKay Development

Passport Steam login and steamcommunity


spenser_l

Recommended Posts

I was wondering if it is possible to use Passport/OpenID for login validation and then transfer the session over to use the node-steamcommunity function calls. 

 

Currently I want to be able to post comments on user profiles, and the following works:

var SteamCommunity = require('steamcommunity');
var ReadLine = require('readline');
var fs = require('fs');

var community = new SteamCommunity();
var rl = ReadLine.createInterface({
	"input": process.stdin,
	"output": process.stdout
});

rl.question("Username: ", function(accountName) {
	rl.question("Password: ", function(password) {
		doLogin(accountName, password);
	});
});

function doLogin(accountName, password, authCode, twoFactorCode, captcha) {
	community.login({
		"accountName": accountName,
		"password": password,
		"authCode": authCode,
		"twoFactorCode": twoFactorCode,
		"captcha": captcha
	}, function(err, sessionID, cookies, steamguard) {
		if(err) {
			if(err.message == 'SteamGuardMobile') {
				rl.question("Steam Authenticator Code: ", function(code) {
					doLogin(accountName, password, null, code);
				});
				return;
			}
			if(err.message == 'SteamGuard') {
				console.log("An email has been sent to your address at " + err.emaildomain);
				rl.question("Steam Guard Code: ", function(code) {
					doLogin(accountName, password, code);
				});
				return;
			}
			if(err.message == 'CAPTCHA') {
				console.log(err.captchaurl);
				rl.question("CAPTCHA: ", function(captchaInput) {
					doLogin(accountName, password, authCode, twoFactorCode, captchaInput);
				});
				return;
			}

			console.log(err);
			process.exit();
			return;
		}

		console.log("Logged on!");

        community.getSteamUser('username', function(err, user){
            if (err) {
                console.log(err);
            } else {
                user.comment('test comment', (err) => {
                    if (err) {
                        console.log(err);
                    } else {
                        console.log('comment posted successfully');
                    }
                });
            }
        });
        return;
	});
}

But the doLogin() function will seem untrustworthy for end-users, so I would want to be able to use the standard "Sign In with Steam" as offered by Passport-Steam.

 

Is there any way for me to do the login via Steam and then transfer those session details/cookies to use steamcommunity?

 

Thanks for any help.

Link to comment
Share on other sites

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...