Jump to content
McKay Development
Lenny McLennington

Using loginKey gives Error: InvalidPassword

Recommended Posts

I am writing the previous username used with the loginKey to a json file.

steamUser.on("loginKey", key => {
  var loginInfo =
  {
    accountName: userInfo.accountName,
    loginKey: key
  };
  var json = JSON.stringify(loginInfo);
  fs.writeFile("./login.json", json, "utf8", err =>
  {
    if (err) {
      console.error(err);
    }
  });
});

userInfo is an object containing accountName and rememberPassword which the user enters on startup.

 

This is the contents of the file "login.json" (Obviously I haven't included the username and loginKey in this post but they are there in the real thing)

{"accountName":"","loginKey":""}

I then load this file and use it with the logOn function:

var SteamUser = require("steam-user");
var steamUser = new SteamUser();

...

var prevLogin = require("login.json");
prevLogin["rememberPassword"] = true;
steamUser.logOn(prevLogin);

Then I get this error:

{ Error: InvalidPassword
    at SteamUser.<anonymous> (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/logon.js:458:16)
    at handlers.forEach (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/classes/HandlerManager.js:37:12)
    at Array.forEach (<anonymous>)
    at HandlerManager.emit (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/classes/HandlerManager.js:36:12)
    at SteamUser._handleMessage (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/messages.js:532:24)
    at SteamUser._handleNetMessage (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/messages.js:467:7)
    at SteamUser.processMulti (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/messages.js:559:9)
    at SteamUser.<anonymous> (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/messages.js:553:16)
    at handlers.forEach (/home/lenny/expanddong/steam-user-testing/node_modules/steam-user/components/classes/HandlerManager.js:37:12)
    at Array.forEach (<anonymous>) eresult: 5 }

So clearly I am doing something wrong. Is there some sort of tutorial on the correct way to do it? Or can someone tell me if they spot a mistake?

Share this post


Link to post
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...