set_login_cookies no longer works (Invalid steam_id)
Hello. About a week ago the library stopped working. I see that the library is broken due to steam update and tried the solution from pull requests by wolfovik. It did work, but set_login_cookies does not work. It throws me this error:
File "", line 33, in <module>
steam_client.set_login_cookies(cookies)
File "/usr/local/lib/python3.11/dist-packages/steampy/client.py", line 78, in set_login_cookies
self.steam_guard = {'steamid': str(self.get_steam_id())}
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/steampy/utils.py", line 23, in func_wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/steampy/client.py", line 89, in get_steam_id
raise ValueError(f'Invalid steam_id: {steam_id}')
ValueError: Invalid steam_id: None
for me it happens when session expire each day. have you tried to add new cookies after this error?
for me it happens when session expire each day. have you tried to add new cookies after this error?
Well, I wrote the program so if the cookies are expired, they are renewed. First I try to login with cookies (I get them from file) and if they are outdated, then I login without cookies. Then, after each login, I write cookies again in file (I get them using steam_client._session.cookies.get_dict()).
for me it happens when session expire each day. have you tried to add new cookies after this error?
Well, I wrote the program so if the cookies are expired, they are renewed. First I try to login with cookies (I get them from file) and if they are outdated, then I login without cookies. Then, after each login, I write cookies again in file (I get them using steam_client._session.cookies.get_dict()).
You are not the only one with this problem, after updating the login.py file nothing helps either. Authorization passes, cookies are created, but it is impossible to log in using cookies with the error "Invalid steam_id"
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)
I made all the corrections on January 21st and everything has been working for me since then
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then You have not changed client.py in any way, it is the default.
I changed login.py yesterday to the code you provided, but still no authorization
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
specially copied everything from your files attached on google drive and tried to authorize through cookies, the result is the same
@Aarab228 Perhaps you changed library files in the wrong environment? For example, you changed files in pycharm, and included the script using cmd If not, please send an exception so I can understand what's going on.
@Aarab228 Perhaps you changed library files in the wrong environment? For example, you changed files in pycharm, and included the script using cmd If not, please send an exception so I can understand what's going on.
I have not changed anything in the library files except for login.py and client.py, the code of which you have given above. The error is "Invalid steam_id: None" when trying to authorize via cookies. Cookies are created at the first login to the account, after which they are used for authorization, but as you understand, authorization fails.
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
Unfortunately, I receive "ValueError: Invalid steam_id: None" as well. Maybe it happens because _session.cookies.get_dict() does not return all cookies?
@Aarab228 Perhaps you changed library files in the wrong environment? For example, you changed files in pycharm, and included the script using cmd If not, please send an exception so I can understand what's going on.
-
uninstall steampy
-
install steampy
-
getting an authorization cookie
-
trying to authorize with cookies and perform an action with the market
Again I get the error invalid steam_id: None. How to fix that, if update by @wolfovik doesn`t work
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
Unfortunately, I receive "ValueError: Invalid steam_id: None" as well. Maybe it happens because _session.cookies.get_dict() does not return all cookies?
I was thinking the same thing, however kind of a quick run through the file, I can't find any deviations
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
How to fix send trade offers? Any idea?
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
How to fix send trade offers? Any idea?
I think you need to replace
session_id = self._get_session_id()
with
self._session.cookies.get_dict()['sessionid']
Atleast that is how I fixed buy_item method for me
I don’t remember exactly what I changed in the library, so I attached the files that I changed -> https://drive.google.com/drive/folders/16fm039KSVq1lWut86SWqG7b7Um0zZAPd?usp=sharing
client.py
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.py
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)I made all the corrections on January 21st and everything has been working for me since then
Could you please make a proper pull request with all changes if everything works fine for you?