aiosteampy icon indicating copy to clipboard operation
aiosteampy copied to clipboard

place_buy_order method doesn't handle steam error codes

Open yesworId opened this issue 7 months ago • 6 comments

Initial Checks

  • [X] I have searched the existing issues for a duplicate and I'm sure this is something new
  • [X] I am confident that the issue in the project code

Description

I was testing this library, after initial login tests I couldn't log into my account. Default login function wasn't working for me. This was error I got: image

Steps To Reproduce

I was using the default login function from this library. Only after I changed code to this one, I logged successfully:

    async def login(self: "SteamCommunityMixin", *, init_data=True, init_session=True):
        """
        Perform login.
        Populate `api_key`, `trade_token`, `wallet_country`, `wallet_currency` fields if it is required.

        :param init_data: fetch initial required data (api key, trade token, wallet_currency/wallet_country)
        :param init_session: init session before start auth process.
            Set this to False if you already make requests to steam from current client.
        :raises ApiError: when failed to obtain rsa key, update steam guard code
        :raises LoginError: other login process errors
        """

        # https://github.com/bukson/steampy/blob/fe0433c8cf7020318cfbbc22e79028a7576374ee/steampy/login.py#L67
        # https://github.com/DoctorMcKay/node-steam-session/blob/698469cdbad3e555dda10c81f580f1ee3960156f/examples/login-to-web-with-2fa.ts#L13
        init_session and await self.session.get(STEAM_URL.COMMUNITY)

        session_data = await self._begin_auth_session_with_credentials()
        await self._update_auth_session_with_steam_guard_code(session_data)
        await self._poll_auth_session_status(session_data)
        fin_data = await self._finalize_login()  # there can be retrieved steam id

        # https://github.com/DoctorMcKay/node-steam-session/blob/64463d7468c1c860afb80164b8c5831e629f657f/src/LoginSession.ts#L845
        transfers = [asyncio.create_task(self._perform_transfer(d, fin_data["steamID"])) for d in
                     fin_data["transfer_info"]]
        done, _ = await asyncio.wait(transfers, return_when=asyncio.FIRST_COMPLETED)

        # Transfers exception check ?

        self._set_web_cookies(done.pop().result())

        init_data and await self._init_data()

        self._is_logged = True

The only change is

        transfers = [asyncio.create_task(self._perform_transfer(d, fin_data["steamID"])) for d in
                     fin_data["transfer_info"]]

But I don't really know is it good or not

Environment

Windows
Python

Additional Information

No response

yesworId avatar Jul 25 '24 18:07 yesworId