async def main(): keys = KeySet.load(PATH_KEYS) info = ProdInfo(keys, PATH_PRODINFO) with open(PATH_TICKET, "rb") as f: ticket = f.read() cert = info.get_tls_cert() pkey = info.get_tls_key() dauth = DAuthClient(keys) dauth.set_certificate(cert, pkey) dauth.set_system_version(SYSTEM_VERSION) response = await dauth.device_token(dauth.BAAS) device_token = response["device_auth_token"] aauth = AAuthClient() aauth.set_system_version(SYSTEM_VERSION) response = await aauth.auth_digital(ACNH.TITLE_ID, ACNH.LATEST_VERSION, device_token, ticket) app_token = response["application_auth_token"] baas = BAASClient() baas.set_system_version(SYSTEM_VERSION) response = await baas.authenticate(device_token) access_token = response["accessToken"] response = await baas.login(BAAS_USER_ID, BAAS_PASSWORD, access_token, app_token) user_id = int(response["user"]["id"], 16) id_token = response["idToken"] auth_info = authentication.AuthenticationInfo() auth_info.token = id_token auth_info.ngs_version = 4 #Switch auth_info.token_type = 2 s = settings.load("switch") s.configure(ACNH.ACCESS_KEY, ACNH.NEX_VERSION, ACNH.CLIENT_VERSION) async with backend.connect(s, HOST, PORT) as be: async with be.login(str(user_id), auth_info=auth_info) as client: mm = matchmaking.MatchmakeExtensionClient(client) param = matchmaking.MatchmakeSessionSearchCriteria() param.attribs = ["", "", "", "", "", ""] param.game_mode = "2" param.min_participants = "1" param.max_participants = "1,8" param.matchmake_system = "1" param.vacant_only = False param.exclude_locked = True param.exclude_non_host_pid = True param.selection_method = 0 param.vacant_participants = 1 param.exclude_user_password = True param.exclude_system_password = True param.refer_gid = 0 param.codeword = CODE sessions = await mm.browse_matchmake_session_no_holder_no_result_range( param) if not sessions: print("\nNo island found for '%s'\n" % CODE) else: session = sessions[0] data = session.application_data print("\nFound island:") print("\tId:", session.id) print("\tActive players:", session.participation_count) print("\tIsland name:", data[12:32].decode("utf16").rstrip("\0")) print("\tHost name:", data[40:60].decode("utf16").rstrip("\0")) print()
# Connect to game server backend = backend.BackEndClient("switch.cfg") backend.configure(ACNH.ACCESS_KEY, ACNH.NEX_VERSION, ACNH.CLIENT_VERSION) backend.connect(HOST, PORT) # Log in on game server auth_info = authentication.AuthenticationInfo() auth_info.token = id_token auth_info.ngs_version = 4 #Switch auth_info.token_type = 2 backend.login(str(user_id), auth_info=auth_info) mm = matchmaking.MatchmakeExtensionClient(backend.secure_client) param = matchmaking.MatchmakeSessionSearchCriteria() param.attribs = ["", "", "", "", "", ""] param.game_mode = "2" param.min_players = "1" param.max_players = "1,8" param.matchmake_system = "1" param.vacant_only = False param.exclude_locked = True param.exclude_non_host_pid = True param.selection_method = 0 param.vacant_participants = 1 param.exclude_user_password = True param.exclude_system_password = True param.refer_gid = 0 param.codeword = CODE