Ryu Posted December 5, 2022 Report Posted December 5, 2022 (edited) Quote import SteamUser from 'steam-user'; import {LoginSession, EAuthTokenPlatformType} from 'steam-session'; let client = new SteamUser(); let session = new LoginSession(EAuthTokenPlatformType.WebBrowser); const loginDetails = { accountName: "name", password: "pass", steamGuardCode: "2fa" } await session.startWithCredentials(loginDetails); session.on('authenticated', async () => { const logOnOptions = { "refreshToken": session.refreshToken }; client.logOn(logOnOptions); client.on('loggedOn', (details) => { console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID()); }); }); What am I doing wrong Edited December 5, 2022 by Ryu Quote
Dr. McKay Posted December 6, 2022 Report Posted December 6, 2022 You need to use EAuthTokenPlatformType.SteamClient. Quote
Ryu Posted December 6, 2022 Author Report Posted December 6, 2022 #Logged into Steam #Error not logged in I'm trying to log into the bot with username, password and 2fa manually, save the refreshToken and cookies, and reuse them anytime I restart the bot. client.logOn({"refreshToken": refreshToken }); client.on('loggedOn', async (details) => { console.log("Logged into Steam"); let manager = new TradeOfferManager({ "steam": client, "domain": "example.com", "language": "en" }); manager.setCookies(cookies, (err) => { manager.getInventoryContents(730, 2, true, (err, inventory) => { if (err) { console.log(err); return; } if (inventory.length == 0) { // Inventory empty console.log("CS:GO inventory is empty"); return; } console.log("Found " + inventory.length + " CS:GO items"); }) }) }); Quote
Dr. McKay Posted December 7, 2022 Report Posted December 7, 2022 Where are you getting cookies from? Quote
Ryu Posted December 7, 2022 Author Report Posted December 7, 2022 I guess I can not save and reuse the cookies because they expire after a few seconds. So if I understand, I can use refreshToken to log in but I can't create trades? Quote
Dr. McKay Posted December 7, 2022 Report Posted December 7, 2022 I haven't tested what happens if you try to use getWebCookies on a SteamClient login session. If you're authenticating with steam-user, you should use the cookies from the webSession event instead. 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.