Open AlanChangICe opened 6 months ago
The simplest way is first update appropriate method from steampy/login.py
, like below
def _update_steam_guard(self, response: Response) -> None:
data = response.json()['response']
client_id = data['client_id']
steamid = data['steamid']
request_id = data['request_id']
code_type = 3
if data['allowed_confirmations'][0]['confirmation_type'] == code_type:
code = guard.generate_one_time_code(self.shared_secret)
update_data = {'client_id': client_id, 'steamid': steamid, 'code_type': code_type, 'code': code}
response = self._api_call(
'POST', 'IAuthenticationService', 'UpdateAuthSessionWithSteamGuardCode', params=update_data
)
if response.status_code == HTTPStatus.OK:
self._pool_sessions_steam(client_id, request_id)
else:
raise Exception('Cannot update Steam guard')
then create file with fake steam guard data (it won`t actually be used to login):
# fakedata.txt
{
"steamid": "just random not empty string",
"shared_secret": "just random not empty string",
"identity_secret": "just random not empty string"
}
and then use it as usual
steam_client.login('myusername', 'mypassword', 'path_to_fakedata.txt')
P.S. I haven`t tested this, but if your account doesn't require login confirmation, it should work
This is my code:
def process_account(account, mafiles, use_proxy):
print(f"开始处理账户: {account['login']}")
result = {'login': account['login']}
try:
steam_guard = mafiles.get(account['login'])
proxy = get_random_proxy() if use_proxy else None
if use_proxy and (proxy is None or 'http' not in proxy):
proxy = f'http://{proxy}' if proxy else None
steam_client = SteamClient(api_key='', proxies={'http': proxy, 'https': proxy} if proxy else {})
if steam_guard:
steam_client.login(username=account['login'], password=account['password'], steam_guard=steam_guard)
print(steam_guard)
print(f"令牌登录成功: {account['login']}")
else:
steam_client.login(username=account['login'], password=account['password'], steam_guard='D:\360data\重要数据\桌面\csgo-rank-checker-2.1.0\fakedata.txt')
print(f"无令牌登录成功: {account['login']}")
I tried your method, but encountered an error: Expecting value: line 1 column 1 (char 0). I still can't solve it. I've modified the _update_steam_guard function as you suggested and also fabricated the Steam Guard file. Here's a Steam account without Steam Guard: Account: sfnkhq4106 Password: VFnlctd85L. Hope this helps you test the error. I'm still trying to figure it out but have no clue.
I tried to login with the provided credentials and received a confirmation type 3, which means that steam guard is bounded to this account. Than, I tried my own accounts, one with steam guard and one without, and the suggested modification works for both. So the problem is somewhere else. Could u provide more information about received exception?
I'm very sorry for the confusion earlier. I've identified the issue. It was because the file path for fakedata.txt wasn't properly escaped with the forward slashes. Specifically, this part of the code caused the problem: steam_client.login(username=account['login'], password=account['password'], steam_guard='D:\360data\重要数据\桌面\csgo-rank-checker-2.1.0\fakedata.txt')
.
The error occurred because the fake token information couldn't be found.
I've now corrected the code to:
steam_client.login(username=account['login'], password=account['password'], steam_guard=r'D:\360data\重要数据\桌面\csgo-rank-checker-2.1.0\fakedata.txt')
,
and the issue is resolved. Thank you for your assistance; I truly appreciate it.
Hello, I am not a professional programmer. Recently, I have been using this project to create a program for bulk adding friends and have been successful. However, the accounts I want to add as friends are not bound to steam guard. Therefore, I am unable to use this project to log in to them. However, due to my limited abilities, I cannot write the logic for logging in without a steam guard. I really need this functionality. Can you update this feature?