Как получить токен авторизации от входа в 2fa Ubisoft? ⇐ Python

Программы на Python
Anonymous
Как получить токен авторизации от входа в 2fa Ubisoft?

Сообщение Anonymous »

Я пытаюсь получить токен аутентификации из входа в систему 2FA Ubisoft, но не могу понять, как его получить, поскольку я просто продолжаю обходить 2FA и получаю токен аутентификации, отличный от 2FA. Я сделал еще один, который дал мне twoFactorAuthenticationTicket, но это все равно не был токен от входа с использованием 2fa.
Это код, который я попробовал, только что превратил в отдельный скрипт для тестирования.< /p>
import requests
import base64
import json

def get_user_headers():
name_email = input("Enter your Ubisoft email: ")
name_password = input("Enter your Ubisoft password: ")
login_url = "https://public-ubiservices.ubi.com/v3/profiles/sessions"

# Logging in to account with name
name_account = name_email + ':' + name_password
name_user = name_account.encode('ascii')
name_auth = base64.b64encode(name_user).decode('ascii')

headers = {
'Authorization': 'Basic ' + name_auth,
'Ubi-AppId': '3168428b-77ba-4381-b85f-a499e8e92290',
'Ubi-RequestedPlatformType': 'uplay',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
'Referer': 'https://connect.ubisoft.com/'
}

name_payload = {
'rememberMe': 'false'
}

name_r = requests.post(login_url, headers=headers, json=name_payload)

if name_r.status_code == 200:
name_res = name_r.json()
if 'ticket' in name_res:
name_auth_token = name_res['ticket']
name_sessionid = name_res['sessionId']

# Update headers with correct Authorization and Ubi-SessionId
headers['Authorization'] = 'Ubi_v1 t=' + name_auth_token
headers['Ubi-SessionId'] = name_sessionid

print("\nLogin successful!")
print(f"Authentication Token: {name_auth_token}")
print(f"Session ID: {name_sessionid}")
print("\nFull response:")
print(json.dumps(name_res, indent=2))

return headers

elif 'twoFactorAuthenticationTicket' in name_res:
while True:
headers["Authorization"] = 'ubi_2fa_v1 t=' + name_res['twoFactorAuthenticationTicket']
headers["Ubi-2FACode"] = input('Enter Two Step Code: ')
swap_t = requests.post(login_url, headers=headers, json={"trustedDevice": None})
if swap_t.status_code == 200:
name_res = swap_t.json()
name_auth_token = name_res['ticket']
name_sessionid = name_res['sessionId']

# Update headers with correct Authorization and Ubi-SessionId
headers['Authorization'] = 'Ubi_v1 t=' + name_auth_token
headers['Ubi-SessionId'] = name_sessionid

print("\nTwo-factor authentication successful!")
print(f"Authentication Token: {name_auth_token}")
print(f"Session ID: {name_sessionid}")
print("\nFull response:")
print(json.dumps(name_res, indent=2))

return headers

elif swap_t.status_code == 400 and 'The two factor authentication code' in swap_t.text:
print("Invalid two factor authentication code. Please try again.")
continue
else:
print(f"Error: Unable to login. Status Code: {name_r.status_code}. Response: {name_r.text}")
return None

if __name__ == "__main__":
headers = get_user_headers()
if headers:
print("\nFinal headers:")
print(json.dumps(headers, indent=2))
else:
print("Login failed.")````


Подробнее здесь: https://stackoverflow.com/questions/790 ... soft-login

Вернуться в «Python»