-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Login problem. Looks like the value of steamLoginSecure cookie is wrong #359
Comments
i use all of this fix client.py #fix cookies login
def set_login_cookies(self, cookies: dict) -> None:
self._session.cookies.update(cookies)
self.was_login_executed = True
if self.steam_guard is None:
self.steam_guard = {'steamid': str(self.get_steam_id())}
self.market._set_login_executed(self.steam_guard, self._get_session_id())
@login_required #fix trade offer
def accept_trade_offer(self, trade_offer_id: str) -> dict:
trade = self.get_trade_offer(trade_offer_id)
trade_offer_state = TradeOfferState(trade['response']['offer']['trade_offer_state'])
if trade_offer_state is not TradeOfferState.Active:
raise ApiException(f'Invalid trade offer state: {trade_offer_state.name} ({trade_offer_state.value})')
partner = self._fetch_trade_partner_id(trade_offer_id)
session_id = self._session.cookies.get_dict("steamcommunity.com")['sessionid']
accept_url = f'{SteamUrl.COMMUNITY_URL}/tradeoffer/{trade_offer_id}/accept'
params = {
'sessionid': session_id,
'tradeofferid': trade_offer_id,
'serverid': '1',
'partner': partner,
'captcha': '',
}
headers = {'Referer': self._get_trade_offer_url(trade_offer_id)}
response = self._session.post(accept_url, data=params, headers=headers).json()
if response.get('needs_mobile_confirmation', False):
return self._confirm_transaction(trade_offer_id)
return response
--------------------------------------------------------------------------------------------------------------------------
login.py # fix cookie login
def set_sessionid_cookies(self):
community_domain = SteamUrl.COMMUNITY_URL[8:]
store_domain = SteamUrl.STORE_URL[8:]
community_cookie_dic = self.session.cookies.get_dict(domain = community_domain)
store_cookie_dic = self.session.cookies.get_dict(domain = store_domain)
for name in ('steamLoginSecure', 'sessionid', 'steamRefresh_steam', 'steamCountry'):
cookie = self.session.cookies.get_dict()[name]
if name in ["steamLoginSecure"]:
store_cookie = create_cookie(name, store_cookie_dic[name], store_domain)
else:
store_cookie = create_cookie(name, cookie, store_domain)
if name in ["sessionid", "steamLoginSecure"]:
community_cookie = create_cookie(name, community_cookie_dic[name], community_domain)
else:
community_cookie = create_cookie(name, cookie, community_domain)
self.session.cookies.set(**community_cookie)
self.session.cookies.set(**store_cookie)
--------------------------------------------------------------------------------------------------------------------------
market.py #fix create_buy_order
@login_required
def create_buy_order(
self,
market_name: str,
price_single_item: str,
quantity: int,
game: GameOptions,
currency: Currency = Currency.USD,
) -> dict:
data = {
#'sessionid': self._session.cookies.get_dict("steamcommunity.com")['sessionid'],
'sessionid': self._session_id,
'currency': currency.value,
'appid': game.app_id,
'market_hash_name': market_name,
'price_total': str(Decimal(price_single_item) * Decimal(quantity)),
'quantity': quantity,
} |
@Aarab228 thank you mate! |
@Aarab228 you are the best! Really helped me! This fix must be committed very much I would only do some refactoring, like def _get_session_id(self) -> str: and don't change accept_trade_offer method. Thix fix also removes errors in such methods like make_offer and others |
yes, but with some moments without my fix u cant send trade, i dont remember with what parameters that connected, but like with returned cookies dict with ["sessionid"] maybe. Anyway, problem with return cookies |
For me error appears.
|
thx, it just work! XD |
Thank you, this really helped, I spent about 2 days solving this problem. But this is the only solution at the moment. For those who are also looking for a solution to this problem, this code will help you. |
Hello everyone!
I have troubleshot with login.
This code executed without errors
But
steam_client.is_session_alive()
has returned False. I verified html content - it is Steam's index page with login form.I analyzed cookies that had occurred after
steam_client.login()
execution in theself._session
. And found out the problem with the "steamLoginSecure" cookie.Because, if I make usual login with browser and take "steamLoginSecure" cookie's value, then put it into next CURL query - everything is perfect.
But if I put value from
self._session
cookie - it doesn't authorize me.Does anyone know what this could be?
The text was updated successfully, but these errors were encountered: