jens1101 / SteamCMD-JS-Interface

Allows you to access and use SteamCMD via JavaScript
14 stars 1 forks source link

ERROR! Not logged on. #11

Closed AndyLee1024 closed 4 years ago

AndyLee1024 commented 4 years ago

Hi developer.

When i use workshop_download_item commands to download workshop item. i got an error : ERROR! Not logged on.

image

jens1101 commented 4 years ago

Thanks for reporting this issue. You unfortunately can't give a password to the init function to log in. You need to use the login function after SteamCmd has initialised in order to login. In addition to your username and password you will also need a Steam Guard code if you have that enabled.

Here is example code of what I mean:

const steamCmd = await SteamCmd.init()

// Now open your Steam app on your mobile phone and get a Steam Guard code.
// I will use 'AABB2' in this example.

await steamCmd.login('username', 'password123', 'AABB2')
console.log(await steamCmd.isLoggedIn()) // Logs "true"

Note that you only have to do this once. After you ran the above code once you can now just run this in the future:

const steamCmd = await SteamCmd.init({
  username: 'username'
})
console.log(await steamCmd.isLoggedIn()) // Logs "true"
jens1101 commented 4 years ago

@AndyLee1024 I just tested out this issue and I also got a login issue. My above comment is incorrect!

To currently solve this issue you need to manually append the login command to your array of commands. For example:

const steamCmd = await SteamCmd.init({
  username: 'username'
})

const commands = [
  'login username',
  'workshop_download_item 255710 445589127'
]

for await (const line of steamCmd.run(commands)) {
  console.log(line)
}

I am currently working on improving this in the next release so that the run command logs you in automatically.