Jump to content
McKay Development

[HELP] Error: Must be logged in before trying to do anything with confirmations


Recommended Posts

Posted

Hi McKay, great fan of your work.

 

I've recently encountered a problem which I do not know how to solve (maybe I'm not informed well enough on how Steam works).

 

Here's the full stack of the problem:

 

Error: Must be logged in before trying to do anything with confirmations
    at request (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:247:9)
    at SteamCommunity.getConfirmations (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:17:2)
    at doConfirmation (/home/f/code/f/node_modules/steamcommunity/components/confirmations.js:182:8)
    at /home/f/code/f/node_modules/steamcommunity/components/confirmations.js:170:4

I am logged in for sure, as I'm trying to trade from the web site I am creating.

 

This is more or less the code for withdraw:

 

 socket.on('withdraw', (data: ItemData) => {
        console.log(`${userObject.personaname} wants to withdraw ${data.assetid}`);

        bot.sendWithdrawTrade(userObject.steamid, userObject.wallet, data.assetid, data.appid,
            (err: any, status: any, tradeOffer: TradeOffer, foundItem: Item) => {
            if (err && !status) {
                logger.error(`Error getting withdraw trade from ${userObject.personaname} because ${err}`);
                socket.emit('withdraw', {
                    error: err,
                });
            } else {
                if (status) {
                    community.acceptConfirmationForObject(process.env.STEAM_IDENTITY_SECRET, tradeOffer.id, (offerError: any) => {
                        if (err) {
                            logger.error(`Error Accepting ${offerError}`);
                        } else {
                           // Update inventory for given item.
                        }
                    });
                } else if (status === 'success') {
                    // Update inventory
                }
                logger.debug(`TradeOffer: ${tradeOffer} ${status}`);
                socket.emit('withdraw', {
                    tradeOffer
                });
            }
        });
    });

 

I'm not really sure what's going on here.

 

I am very much logged in like so:

 


const loginOptions = {
    accountName: process.env.STEAM_USER_NAME,
    password: process.env.STEAM_USER_PASSWORD,
    twoFactorCode: SteamTotp.generateAuthCode(process.env.STEAM_SHARED_SECRET)
};

and the logged in functionalities have never been a problem until now. 

Thanks for any help and sorry for taking your time.

 

Barak

Posted

You probably have some sort of race condition somewhere resulting in you attempting to accept a confirmation before you actually call login. That particular error happens if you attempt to accept a confirmation without ever having logged in before (on that SteamCommunity instance), so this isn't a case of expired cookies.

Posted
8 hours ago, Dr. McKay said:

You probably have some sort of race condition somewhere resulting in you attempting to accept a confirmation before you actually call login. That particular error happens if you attempt to accept a confirmation without ever having logged in before (on that SteamCommunity instance), so this isn't a case of expired cookies.

Thanks for the prompt response. 

I'm making the withdraw request from a website. When a user clicks on an item it withdraws it from the bot's inventory, which should mean the steam user is logged on. Here's a log:

 

{"message":"Logged into steam as **********","level":"info"}
{"message":"Currently 0,09€ Steam Wallet credit. ","level":"info"}
{"message":"Is limited: false. Is cBanned false.\n            Can Invite Friends: true, Is Locked: false","level":"info"}
{"message":"Client Connected as WEBSITE_USER.","level":"debug"}
{"message":"User WEBSITE_USER has a wallet of 45 eur","level":"info"}
{"message":"Session Initialized.","level":"debug"}
{"message":"Cookies, sessionid=5***,steamLogin=7****,steamLoginSecure=7****","level":"debug"}
{"message":"Trade cookies set. API KEY: 5*****","level":"info"}
{"message":"Updating Inventory collection...","level":"debug"}
{"message":"Length of __BOT__ items: 439","level":"debug"}
{"message":"Updated Inventory for Bot with id: 7****","level":"info"}
WEBSITE_USER wants to withdraw assetid
{"message":"TradeOffer: 3811117774 true","level":"debug"}
Error: Must be logged in before trying to do anything with confirmations

 

The withdraw happened a while (30sec?) after I started the server.

 

This is how I set the cookies:

 

this.client.on('webSession', (sessionid: any, cookies: any) => {
            logger.debug('Session Initialized.');
            logger.debug(`Cookies, ${cookies}`);
            this.manager.setCookies(cookies, (err: any) => {

                /* Cannot set cookies on, as it is still limited account */
                if (err) {
                    logger.error(`Unable to set trade cookies: ${err}`);
                    return;
                    // process.exit(1);

                }

                logger.info(`Trade cookies set. API KEY: ${this.manager.apiKey}`);

                /* Gets all of the Bot's inventory and stores it into inventory Collection
                Momentarily only for the Bot's Dota 2 inventory. */
                this.fillInventoryOnInit();

                /* Accepts all friend requests. Logs unfriends. */
                this.initFriendRequestListener();

                /* Listens to a chat message from a user. Currently supports only !help */
                this.onFriendMessageListener();

                /* Accepts all pending requests and logs all messages
                that occured while bot was offline */
                this.checkFriendsAndMessagesWhileOffline();

                /* Logs all new offers, and accepts only if its a donation
                or the trader is the admin*/
                this.initNewOfferListener();

            });

            this.community.setCookies(cookies);
            this.community.startConfirmationChecker(10000, process.env.STEAM_IDENTITY_SECRET);
        });

and this is the withdraw implementation

 

    public sendWithdrawTrade(partner: any, credits: any, assetid: any, gameid: any, cb: Function) {
        console.log(assetid, gameid);
        const offer = this.manager.createOffer(partner);

        this.manager.getInventoryContents(gameid, RequestConfig.contextid.GAMES, true, (err: any, inv: any) => {
            if (err) {
                return logger.error(`Failed while fetching inventory with ${err}`);
            }

            const foundItem = inv.find((item: any) => item.assetid === assetid);

            if (foundItem) {
                offer.addMyItem(foundItem);
                offer.setMessage('Withdraw item.');
                offer.send((offerError: any, status: any) => {
                    cb(offerError, (status === 'sent' || status === 'pending'), offer.id, foundItem);
                });
            } else {
               return cb(new Error('Could not find item'), false);
            }
        });
    }

Maybe it has something to do with the web request not sending the cookies through the socket, but I doubt it...

 

This also fires (as it appears in the log above):

 

        /* Fires if succesfully logged in */
        this.client.on('loggedOn', () => {
            logger.info(`Logged into steam as ${this.client.steamID}`);

            // Sets the Bot status to 'Looking To Trade'
            this.client.setPersona(EPersonaState.LookingToTrade);
            // game.id(570) = Dota 2;
            // Can set only free games. Or paid games that Bot Owns.
            this.client.gamesPlayed(RequestConfig.appid.DOTA2);

        });

 

Sorry for the long reply, don't really know where to go from here.

 

One thing to mention is that the offers are stuck on `Waiting Mobile Confirmation` or something when I check them manually through Steam. Thanks!

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