steampy icon indicating copy to clipboard operation
steampy copied to clipboard

login cookie still not working

Open Aarab228 opened this issue 1 year ago • 7 comments

I tried reinstalling the library and/or using other users' solutions, nothing helped, however @xidios solution helped solve the problem with authorization and cookie creation after the first connection. However, when trying to authorize via cookies - I get the error Invalid steam_id: None. Honestly, tried even on macOS to test, still the same thing, although I know that it is related to the update of steam. Does anyone have a solution, how to return authorization by cookie, because every time authorize manually - a bad idea....

Fix by @xidios:

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)

Aarab228 avatar Jan 26 '24 20:01 Aarab228

Hi, I am using cookie authentication in my selenium script, I am taking these cookies client._session.cookies.get_dict("steamcommunity.com")

client is SteamClient in steampy library

xidios avatar Jan 27 '24 13:01 xidios

Hi, I am using cookie authentication in my selenium script, I am taking these cookies client._session.cookies.get_dict("steamcommunity.com")

client is SteamClient in steampy library

Is it alright if there are only 'sessionid' and 'steamCountry'?

HappyWaffle566 avatar Jan 27 '24 17:01 HappyWaffle566

Hi, I am using cookie authentication in my selenium script, I am taking these cookies client._session.cookies.get_dict("steamcommunity.com") client is SteamClient in steampy library

Is it alright if there are only 'sessionid' and 'steamCountry'?

image I have this cookie set

xidios avatar Jan 27 '24 19:01 xidios

Hi, I am using cookie authentication in my selenium script, I am taking these cookies client._session.cookies.get_dict("steamcommunity.com") client is SteamClient in steampy library

Is it alright if there are only 'sessionid' and 'steamCountry'?

image I have this cookie set

Hm, that's weird. I have exact fix and when I get cookies the way you do, I only have these two. Are you sure you haven't changed anything else?

I found the problem. It feels like SteamPy gives two different jsons and one overwrites another

Yes, it works now. Thank you

HappyWaffle566 avatar Jan 27 '24 19:01 HappyWaffle566

where i need to write?

client._session.cookies.get_dict("steamcommunity.com")

Aarab228 avatar Jan 28 '24 06:01 Aarab228

where i need to write?

client._session.cookies.get_dict("steamcommunity.com")

These are cookies you get. You can use them, for example, in set_login_cookies

HappyWaffle566 avatar Jan 28 '24 08:01 HappyWaffle566

Hi, I am using cookie authentication in my selenium script, I am taking these cookies client._session.cookies.get_dict("steamcommunity.com")

client is SteamClient in steampy library

OMFG, IT`S WORK NOW, THANKS

Aarab228 avatar Jan 28 '24 20:01 Aarab228