steampy icon indicating copy to clipboard operation
steampy copied to clipboard

Unable to obtain session ID during login

Open a1063815047 opened this issue 10 months ago • 24 comments

steam_client.login(username, newpassword, 'new_filename') File "/usr/local/python3/lib/python3.8/site-packages/steampy/client.py", line 132, in login LoginExecutor(self.username, self._password, self.steam_guard['shared_secret'], self._session).login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 43, in login finalized_response = self._finalize_login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 151, in _finalize_login sessionid = self.session.cookies['sessionid'] File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 334, in getitem return self._find_no_duplicates(name) File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 413, in _find_no_duplicates raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") KeyError: "name='sessionid', domain=None, path=None"

a1063815047 avatar Feb 12 '25 03:02 a1063815047

Same. _finallize_login now returns with 403 code. Must be Steam changed authorization procedure.

wolfovik avatar Feb 12 '25 03:02 wolfovik

Same. _finallize_login now returns with 403 code. Must be Steam changed authorization procedure.

Yes, it was normal an hour ago

a1063815047 avatar Feb 12 '25 03:02 a1063815047

Same.

vmee avatar Feb 12 '25 03:02 vmee

Same. Actually I can see my device in autorized devices after login, but still I can't pass through steam.login method. Also someone mentioned that you can't bulk confirm trades in SDA, but you can do it one by one

delta325 avatar Feb 12 '25 03:02 delta325

same

idimo avatar Feb 12 '25 04:02 idimo

No more sessionID in finalize_login:{'response': {'client_id': '14948508085995000000', 'request_id': '5WzFBXbdwBAfH4QXDza9zA==', 'interval': 0.10000000149011612, 'allowed_confirmations': [{'confirmation_type': 1}], 'steamid': '76561199674400000'}}

pythonMaster2002 avatar Feb 12 '25 08:02 pythonMaster2002

@ #432 Here's my fix. I can't test it myself, but it passed all the tests.

wolfovik avatar Feb 12 '25 08:02 wolfovik

@ #432 这是我的修复方法。我无法亲自测试,但它通过了所有测试。

steam_client.login(username, newpassword, 'new_filename')

File "/usr/local/python3/lib/python3.8/site-packages/steampy/client.py", line 132, in login LoginExecutor(self.username, self._password, self.steam_guard['shared_secret'], self._session).login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 43, in login finalized_response = self._finalize_login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 154, in _finalize_login sessionid = self.session.cookies['sessionid'] File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 334, in getitem return self._find_no_duplicates(name) File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 413, in _find_no_duplicates raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") KeyError: "name='sessionid', domain=None, path=None"

Unfortunately, using your method still results in this error

a1063815047 avatar Feb 12 '25 08:02 a1063815047

Try again, I updated it

wolfovik avatar Feb 12 '25 08:02 wolfovik

same,response <403> has been about 6 hours, is here any good idea?

 redir = "https://steamcommunity.com/login/home/?goto="

finallez_data = {
                'nonce': self.refresh_token,
                'sessionid': sessionid,
                'redir': redir
            }

response = self.session.post("https://login.steampowered.com/jwt/finalizelogin", data=finallez_data, proxies=proxies)

I saw the post URL, and the data has not changed. The nonce information comes from the API, so I think the code does not need to be fixed. So, what's wrong?

ZangYUzhang avatar Feb 12 '25 08:02 ZangYUzhang

Try again, I updated it

steam_client.login(username, newpassword, 'new_filename')

File "/usr/local/python3/lib/python3.8/site-packages/steampy/client.py", line 132, in login LoginExecutor(self.username, self._password, self.steam_guard['shared_secret'], self._session).login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 43, in login finalized_response = self._finalize_login() File "/usr/local/python3/lib/python3.8/site-packages/steampy/login.py", line 155, in _finalize_login sessionid = self.session.cookies['sessionid'] File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 334, in getitem return self._find_no_duplicates(name) File "/usr/local/python3/lib/python3.8/site-packages/requests/cookies.py", line 413, in _find_no_duplicates raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}")

It's still the same error

a1063815047 avatar Feb 12 '25 08:02 a1063815047

Try again, I updated it

waiting u next upload..

ZangYUzhang avatar Feb 12 '25 08:02 ZangYUzhang

Alright, then try commit 6e058b4f66f588c984aab05b585b5c21b59f9ebd. It's hard for me to say why they don't work; I have a parallel branch. Everything is working for me right now.

wolfovik avatar Feb 12 '25 08:02 wolfovik

Try again, I updated it

After your 3rd update it works. You are the best.

delta325 avatar Feb 12 '25 08:02 delta325

好的,然后尝试提交6e058b4。我很难说为什么它们不起作用;我有一个并行分支。现在一切都正常。

Perfect solution, that's great

a1063815047 avatar Feb 12 '25 08:02 a1063815047

Great, see you on the market :)

wolfovik avatar Feb 12 '25 08:02 wolfovik

Great, see you on the market :)

great!! here is the fixed code。

def _finalize_login(self, proxies: dict | None = None) -> requests.Response:
            redir = "https://steamcommunity.com/login/home/?goto="
            files = {
                'nonce': (None, self.refresh_token),
                'sessionid': (None, sessionid),
                'redir': (None, redir)
            }
            headers = {
                'Referer': redir,
                'Origin': 'https://steamcommunity.com'
            }
            return self.session.post("https://login.steampowered.com/jwt/finalizelogin", headers=headers, files=files)

ZangYUzhang avatar Feb 12 '25 09:02 ZangYUzhang

Alright, then try commit 6e058b4. It's hard for me to say why they don't work; I have a parallel branch. Everything is working for me right now.

Thanks man, you're the best!

idimo avatar Feb 12 '25 10:02 idimo

the new problem is add friend was response 403 too

ZangYUzhang avatar Feb 12 '25 13:02 ZangYUzhang

i got it, the problem is the request headers, must appoint an Referer and Origin into the headers, else response 403

ZangYUzhang avatar Feb 12 '25 14:02 ZangYUzhang

Alright, then try commit 6e058b4. It's hard for me to say why they don't work; I have a parallel branch. Everything is working for me right now.

Thanks! Good solution, worked for me

lspeed-v avatar Feb 12 '25 14:02 lspeed-v

sadly make_offer_with_url() also broke :( - response = self._session.get(url, data=params, headers=headers).json() is returning None.

would be very thankful if someone could fix it.

VlexWest avatar Feb 12 '25 21:02 VlexWest

@VlexWest Unfortunately, I can't test this either. But just by analogy, try this option for make_offer_with_url():

params = {
    'sessionid': session_id,
    'serverid': server_id,
    'partner': partner_steam_id,
    'tradeoffermessage': message,
    'json_tradeoffer': json.dumps(offer),
    'captcha': '',
    'trade_offer_create_params': json.dumps(trade_offer_create_params),
}

files = {key: (None, str(value)) for key, value in params.items()}

headers = {
    'Referer': f'{SteamUrl.COMMUNITY_URL}{urlparse.urlparse(trade_offer_url).path}',
    'Origin': SteamUrl.COMMUNITY_URL,
}

response = self._session.post(url, files=files, headers=headers).json()

wolfovik avatar Feb 12 '25 22:02 wolfovik

Sadly not working :( Image

VlexWest avatar Feb 13 '25 14:02 VlexWest