mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
generate_emu_config: Fix credentials
use an updated fork
This commit is contained in:
parent
5b02ecb1cf
commit
481bd94cbf
@ -6,8 +6,7 @@ from external_components import (
|
|||||||
)
|
)
|
||||||
from controller_config_generator import parse_controller_vdf
|
from controller_config_generator import parse_controller_vdf
|
||||||
from steam.client import SteamClient
|
from steam.client import SteamClient
|
||||||
from steam.client.cdn import CDNClient
|
from steam.webauth import WebAuth
|
||||||
from steam.enums import common
|
|
||||||
from steam.enums.common import EResult
|
from steam.enums.common import EResult
|
||||||
from steam.enums.emsg import EMsg
|
from steam.enums.emsg import EMsg
|
||||||
from steam.core.msg import MsgProto
|
from steam.core.msg import MsgProto
|
||||||
@ -691,11 +690,14 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
client = SteamClient()
|
client = SteamClient()
|
||||||
login_tmp_folder = os.path.join(get_exe_dir(RELATIVE_DIR), "login_temp")
|
if ANON_LOGIN:
|
||||||
if not os.path.exists(login_tmp_folder):
|
result = client.anonymous_login()
|
||||||
os.makedirs(login_tmp_folder)
|
trials = 5
|
||||||
client.set_credential_location(login_tmp_folder)
|
while result != EResult.OK and trials > 0:
|
||||||
|
time.sleep(1000)
|
||||||
|
result = client.anonymous_login()
|
||||||
|
trials -= 1
|
||||||
|
else:
|
||||||
# first read the 'my_login.txt' file
|
# first read the 'my_login.txt' file
|
||||||
my_login_file = os.path.join(get_exe_dir(RELATIVE_DIR), "my_login.txt")
|
my_login_file = os.path.join(get_exe_dir(RELATIVE_DIR), "my_login.txt")
|
||||||
if not ANON_LOGIN and os.path.isfile(my_login_file):
|
if not ANON_LOGIN and os.path.isfile(my_login_file):
|
||||||
@ -716,41 +718,28 @@ def main():
|
|||||||
if env_password:
|
if env_password:
|
||||||
PASSWORD = env_password
|
PASSWORD = env_password
|
||||||
|
|
||||||
|
# still no username? ask user
|
||||||
|
if not USERNAME:
|
||||||
|
USERNAME = input("Steam user: ")
|
||||||
|
|
||||||
if ANON_LOGIN:
|
# the file to save/load credentials
|
||||||
result = client.anonymous_login()
|
REFRESH_TOKENS = os.path.join(get_exe_dir(RELATIVE_DIR), "refresh_tokens.json")
|
||||||
trials = 5
|
refresh_tokens = {}
|
||||||
while result != EResult.OK and trials > 0:
|
if os.path.isfile(REFRESH_TOKENS):
|
||||||
time.sleep(1000)
|
with open(REFRESH_TOKENS) as f:
|
||||||
result = client.anonymous_login()
|
try:
|
||||||
trials -= 1
|
lf = json.load(f)
|
||||||
elif (len(USERNAME) == 0 or len(PASSWORD) == 0):
|
refresh_tokens = lf if isinstance(lf, dict) else {}
|
||||||
client.cli_login()
|
except:
|
||||||
else:
|
pass
|
||||||
result = client.login(USERNAME, password=PASSWORD)
|
REFRESH_TOKEN = refresh_tokens.get(USERNAME)
|
||||||
auth_code, two_factor_code = None, None
|
|
||||||
|
webauth, result = WebAuth(), None
|
||||||
while result in (
|
while result in (
|
||||||
EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode,
|
|
||||||
EResult.AccountLoginDeniedNeedTwoFactor, EResult.TwoFactorCodeMismatch,
|
|
||||||
EResult.TryAnotherCM, EResult.ServiceUnavailable,
|
EResult.TryAnotherCM, EResult.ServiceUnavailable,
|
||||||
EResult.InvalidPassword,
|
EResult.InvalidPassword, None):
|
||||||
):
|
|
||||||
|
|
||||||
if result == EResult.InvalidPassword:
|
if result in (EResult.TryAnotherCM, EResult.ServiceUnavailable):
|
||||||
print("invalid password, the password you set is wrong.")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
elif result in (EResult.AccountLogonDenied, EResult.InvalidLoginAuthCode):
|
|
||||||
prompt = ("Enter email code: " if result == EResult.AccountLogonDenied else
|
|
||||||
"Incorrect code. Enter email code: ")
|
|
||||||
auth_code, two_factor_code = input(prompt), None
|
|
||||||
|
|
||||||
elif result in (EResult.AccountLoginDeniedNeedTwoFactor, EResult.TwoFactorCodeMismatch):
|
|
||||||
prompt = ("Enter 2FA code: " if result == EResult.AccountLoginDeniedNeedTwoFactor else
|
|
||||||
"Incorrect code. Enter 2FA code: ")
|
|
||||||
auth_code, two_factor_code = None, input(prompt)
|
|
||||||
|
|
||||||
elif result in (EResult.TryAnotherCM, EResult.ServiceUnavailable):
|
|
||||||
if prompt_for_unavailable and result == EResult.ServiceUnavailable:
|
if prompt_for_unavailable and result == EResult.ServiceUnavailable:
|
||||||
while True:
|
while True:
|
||||||
answer = input("Steam is down. Keep retrying? [y/n]: ").lower()
|
answer = input("Steam is down. Keep retrying? [y/n]: ").lower()
|
||||||
@ -760,8 +749,25 @@ def main():
|
|||||||
if answer == 'n': break
|
if answer == 'n': break
|
||||||
|
|
||||||
client.reconnect(maxdelay=15)
|
client.reconnect(maxdelay=15)
|
||||||
|
elif result == EResult.InvalidPassword:
|
||||||
|
print("invalid password or refresh_token,")
|
||||||
|
print(f"correct the password or/and delete '{REFRESH_TOKENS}' and try again.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
result = client.login(USERNAME, PASSWORD, None, auth_code, two_factor_code)
|
if not REFRESH_TOKEN:
|
||||||
|
try:
|
||||||
|
webauth.cli_login(USERNAME, PASSWORD)
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Unknown exception: {e}, maybe some account info is wrong?')
|
||||||
|
exit(1)
|
||||||
|
USERNAME, PASSWORD = webauth.username, webauth.password
|
||||||
|
REFRESH_TOKEN = webauth.refresh_token
|
||||||
|
|
||||||
|
result = client.login(USERNAME, PASSWORD, REFRESH_TOKEN)
|
||||||
|
|
||||||
|
with open(REFRESH_TOKENS, 'w') as f:
|
||||||
|
refresh_tokens.update({USERNAME: REFRESH_TOKEN})
|
||||||
|
json.dump(refresh_tokens,f,indent=4)
|
||||||
|
|
||||||
# read and prepend top_owners_ids.txt
|
# read and prepend top_owners_ids.txt
|
||||||
top_owners_file = os.path.join(get_exe_dir(RELATIVE_DIR), "top_owners_ids.txt")
|
top_owners_file = os.path.join(get_exe_dir(RELATIVE_DIR), "top_owners_ids.txt")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
steam[client]
|
steam[client] @ git+https://github.com/detiam/steam_websocket@b8239912e6a190f490aede529c08b5049096bdc8
|
||||||
pyinstaller
|
pyinstaller
|
||||||
requests
|
requests
|
||||||
certifi
|
certifi
|
||||||
|
Loading…
Reference in New Issue
Block a user