Skip to content
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

Unable to obtain session ID during login #431

Open
a1063815047 opened this issue Feb 12, 2025 · 24 comments
Open

Unable to obtain session ID during login #431

a1063815047 opened this issue Feb 12, 2025 · 24 comments

Comments

@a1063815047
Copy link

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"

@wolfovik
Copy link
Contributor

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

@a1063815047
Copy link
Author

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

Yes, it was normal an hour ago

@vmee
Copy link

vmee commented Feb 12, 2025

Same.

@delta325
Copy link

delta325 commented Feb 12, 2025

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

@idimo
Copy link

idimo commented Feb 12, 2025

same

@pythonMaster2002
Copy link

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

@wolfovik
Copy link
Contributor

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

@a1063815047
Copy link
Author

@ #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

@wolfovik
Copy link
Contributor

Try again, I updated it

@ZangYUzhang
Copy link

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?

@a1063815047
Copy link
Author

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

@ZangYUzhang
Copy link

Try again, I updated it

waiting u next upload..

@wolfovik
Copy link
Contributor

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.

@delta325
Copy link

Try again, I updated it

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

@a1063815047
Copy link
Author

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

Perfect solution, that's great

@wolfovik
Copy link
Contributor

Great, see you on the market :)

@ZangYUzhang
Copy link

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)

@idimo
Copy link

idimo commented Feb 12, 2025

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!

@ZangYUzhang
Copy link

the new problem is add friend was response 403 too

@ZangYUzhang
Copy link

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

@lspeed-v
Copy link

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

@VlexWest
Copy link

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.

@wolfovik
Copy link
Contributor

wolfovik commented Feb 12, 2025

@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()

@VlexWest
Copy link

Sadly not working :(
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants