Example #1
0
async def main():
	s = settings.load("friends")
	s.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION)
	
	async with backend.connect(s, "127.0.0.1", 1223) as be:
		async with be.login_guest() as client:
			pass
Example #2
0
async def main():
	nas = nnas.NNASClient()
	nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
	nas.set_title(MK8.TITLE_ID_EUR, MK8.LATEST_VERSION)
	nas.set_locale(REGION_ID, COUNTRY_NAME, LANGUAGE)
	
	access_token = await nas.login(USERNAME, PASSWORD)
	nex_token = await nas.get_nex_token(access_token.token, MK8.GAME_SERVER_ID)
	
	s = settings.default()
	s.configure(MK8.ACCESS_KEY, MK8.NEX_VERSION)
	async with backend.connect(s, nex_token.host, nex_token.port) as be:
		async with be.login(str(nex_token.pid), nex_token.password) as client:
			ranking_client = ranking.RankingClient(client)
	
			order_param = ranking.RankingOrderParam()
			order_param.order_calc = ranking.RankingOrderCalc.ORDINAL
			order_param.offset = 499 #Start at 500th place
			order_param.count = 20 #Download 20 highscores
	
			rankings = await ranking_client.get_ranking(
				ranking.RankingMode.GLOBAL, TRACK_ID,
				order_param, 0, 0
			)
	
			ranking_stats = await ranking_client.get_stats(
				TRACK_ID, order_param, ranking.RankingStatFlags.ALL
			)
		
			names = await nas.get_nnids([data.pid for data in rankings.data])
	
			#Print some interesting stats
			stats = ranking_stats.stats
			print("Total:", int(stats[0]))
			print("Total time:", format_time(stats[1]))
			print("Lowest time:", format_time(stats[2]))
			print("Highest time:", format_time(stats[3]))
			print("Average time:", format_time(stats[4]))
	
			print("Rankings:")
			for rankdata in rankings.data:
				time = format_time(rankdata.score)
				print("\t%5i   %20s   %s" %(rankdata.rank, names[rankdata.pid], time))
		
			#Let's download the replay file of whoever is in 500th place
			store = datastore.DataStoreClient(client)
			
			rankdata = rankings.data[0]
			get_param = datastore.DataStorePrepareGetParam()
			get_param.persistence_target.owner_id = rankdata.pid
			get_param.persistence_target.persistence_id = TRACK_ID - 16
			get_param.extra_data = ["WUP", str(REGION_ID), REGION_NAME, str(COUNTRY_ID), COUNTRY_NAME, ""]
			
			req_info = await store.prepare_get_object(get_param)
			headers = {header.key: header.value for header in req_info.headers}
			response = await http.get(req_info.url, headers=headers)
			response.raise_if_error()
			
			with open("replay.bin", "wb") as f:
				f.write(response.body)
Example #3
0
async def main():
    nas = nnas.NNASClient()
    nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
    nas.set_title(DKCTF.TITLE_ID_EUR, DKCTF.LATEST_VERSION)
    nas.set_locale(REGION, COUNTRY, LANGUAGE)

    access_token = await nas.login(USERNAME, PASSWORD)
    nex_token = await nas.get_nex_token(access_token.token,
                                        DKCTF.GAME_SERVER_ID)

    s = settings.default()
    s.configure(DKCTF.ACCESS_KEY, DKCTF.NEX_VERSION)
    async with backend.connect(s, nex_token.host, nex_token.port) as be:
        async with be.login(str(nex_token.pid), nex_token.password) as client:
            order_param = ranking.RankingOrderParam()
            order_param.offset = 0  #Start with the world record
            order_param.count = 20  #Download 20 highscores

            ranking_client = ranking.RankingClient(client)
            rankings = await ranking_client.get_ranking(
                ranking.RankingMode.GLOBAL,  #Get the global leaderboard
                0x893EB726,  #Category, this is 3-A (Magrove Cove)
                order_param,
                0,
                0)

            print("Total:", rankings.total)
            print("Rankings:")
            for rankdata in rankings.data:
                seconds = (rankdata.score >> 1) / 60
                time = "%i:%02i.%02i" % (seconds / 60, seconds % 60,
                                         (seconds * 100) % 100)
                damage = " Damaged " if rankdata.score & 1 else "No damage"
                kong = ["No Kong", "Diddy", "Dixie",
                        "Cranky"][rankdata.groups[1]]
                name = rankdata.common_data.decode("ascii")[:-1]

                print("\t%2i   %20s   %s (%s)   %s" %
                      (rankdata.rank, name, time, damage, kong))

            #Now download the world record replay file if available
            world_record = rankings.data[0]
            if world_record.param:  #If world record has a replay file
                store = datastore.DataStoreClient(client)

                get_param = datastore.DataStorePrepareGetParam()
                get_param.data_id = world_record.param

                req_info = await store.prepare_get_object(get_param)
                headers = {
                    header.key: header.value
                    for header in req_info.headers
                }
                response = await http.get(req_info.url, headers=headers)
                response.raise_if_error()

                with open("replay.bin", "wb") as f:
                    f.write(response.body)
Example #4
0
async def backend_setup():
    global datastore_smm_client

    s = settings.default()
    s.configure(SMM.ACCESS_KEY, SMM.NEX_VERSION)

    async with backend.connect(s, nex_token.host, nex_token.port) as be:
        async with be.login(str(nex_token.pid), nex_token.password) as client:
            datastore_smm_client = datastore_smm.DataStoreClientSMM(client)

            await scrape()  # start ripping courses
Example #5
0
async def test_backend():
    s = settings.default()

    auth_servers = [AuthenticationServer(s)]
    secure_servers = [AccountManagementServer()]
    async with rmc.serve(s, auth_servers, HOST, 12345):
        async with rmc.serve(s, secure_servers, HOST, 12346, key=b"testkey"):
            async with backend.connect(s, HOST, 12345) as client:
                async with client.login("username",
                                        "password") as secure_client:
                    act = account.AccountClient(secure_client)
                    assert await act.get_name(1000) == "test"
Example #6
0
async def main():
    client = nasc.NASCClient()
    client.set_title(Friends3DS.TITLE_ID_EUR, Friends3DS.LATEST_VERSION)
    client.set_device(SERIAL_NUMBER, MAC_ADDRESS, DEVICE_CERT, DEVICE_NAME)
    client.set_locale(REGION, LANGUAGE)
    client.set_user(PID, PID_HMAC)

    response = await client.login(Friends3DS.GAME_SERVER_ID)

    s = settings.load("friends")
    s.configure(Friends3DS.ACCESS_KEY, Friends3DS.NEX_VERSION)
    async with backend.connect(s, response.host, response.port) as be:
        async with be.login(str(PID), NEX_PASSWORD) as client:
            friends_client = friends.FriendsClientV1(client)
            await friends_client.update_comment("Hello World")
Example #7
0
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(SMM2.TITLE_ID, SMM2.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(SMM2.ACCESS_KEY, SMM2.NEX_VERSION, SMM2.CLIENT_VERSION)
    async with backend.connect(s, HOST, PORT) as be:
        async with be.login(str(user_id), auth_info=auth_info) as client:
            # Search for ninji courses
            store = datastore.DataStoreClientSMM2(client)

            param = datastore.SearchCoursesEventParam()
            courses = await store.search_courses_event(param)
            print("Found %i ninji courses.\n" % len(courses))

            # Print information about the oldest ninji course
            course = courses[-1]
            print("Name:", course.name)
            print("Description:", course.description)
            print("Start time:", course.upload_time)
            print("End time:", course.end_time)
            print()

            # Request ghost info
            param = datastore.GetEventCourseGhostParam()
            param.data_id = course.data_id
            param.time = 30000  # Request ghosts with a time around 30 seconds
            param.count = 1  # Only request a single ghost

            ghost = (await store.get_event_course_ghost(param))[0]

            # Request info about the ghost player
            param = datastore.GetUsersParam()
            param.pids = [ghost.pid]

            user = (await store.get_users(param)).users[0]
            print("Player:", user.name)
            print("Time: %i.%03i" % (ghost.time // 1000, ghost.time % 1000))
            print()

            # Download replay file
            header_info = await store.get_req_get_info_headers_info(
                ghost.replay_file.data_type)
            headers = {h.key: h.value for h in header_info.headers}
            response = await http.get(ghost.replay_file.url, headers=headers)
            response.raise_if_error()

            # Decompress and save replay file
            data = zlib.decompress(response.body)
            with open("replay.bin", "wb") as f:
                f.write(data)
from nintendo.nex import backend, authentication, ranking
from nintendo.games import MK8Deluxe

TRACK_ID = 10  #Sunshine airport

HOST = "g%08x-lp1.s.n.srv.nintendo.net" % MK8Deluxe.GAME_SERVER_ID
PORT = 443

backend = backend.BackEndClient(MK8Deluxe.ACCESS_KEY, MK8Deluxe.NEX_VERSION,
                                backend.Settings("switch.cfg"))
backend.connect(HOST, PORT)
backend.login_guest()

order_param = ranking.RankingOrderParam()
order_param.order_calc = ranking.RankingOrderCalc.ORDINAL
order_param.offset = 0  #Start with world record
order_param.count = 20  #Download 20 highscores

ranking_client = ranking.RankingClient(backend.secure_client)
rankings = ranking_client.get_ranking(ranking.RankingMode.GLOBAL, TRACK_ID,
                                      order_param, 0, 0)

stats = ranking_client.get_stats(TRACK_ID, order_param,
                                 ranking.RankingStatFlags.ALL).stats


def format_time(score):
    millisec = score % 1000
    seconds = score // 1000 % 60
    minutes = score // 1000 // 60
    return "%i:%02i.%03i" % (minutes, seconds, millisec)
Example #9
0
                           small_image="nn",
                           small_text=MAINID,
                           large_image=title_id.lower())

        else:
            print("Unknown notification type %i (from %s)" %
                  (event.type, name))

    def process_presence_change_event(self, context, event):
        self.process_nintendo_notification_event(context, event)


nnas = nnas.NNASClient()
nnas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
nnas.set_locale(REGION, COUNTRY, LANGUAGE)
nnas.set_title(Friends.TITLE_ID_EUR, Friends.LATEST_VERSION)
nnas.login(USERNAME, PASSWORD)

nex_token = nnas.get_nex_token(Friends.GAME_SERVER_ID)
backend = backend.BackEndClient("friends.cfg")
backend.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION)
backend.connect(nex_token.host, nex_token.port)

login_data = authentication.NintendoLoginData()
login_data.token = nex_token.token
backend.login(nex_token.username, nex_token.password, None, login_data)
backend.secure_client.register_server(NotificationServer())

input("Press enter to disconnect and exit\n")
backend.close()
Example #10
0
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()
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(GBG.TITLE_ID, GBG.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(GBG.ACCESS_KEY, GBG.NEX_VERSION, GBG.CLIENT_VERSION)
    async with backend.connect(s, HOST, PORT) as be:
        async with be.login(str(user_id), auth_info=auth_info) as client:
            store = datastore.DataStoreClient(client)

            # Request meta data
            param = datastore.DataStoreGetMetaParam()
            param.data_id = code_to_data_id(GAME_CODE)

            meta = await store.get_meta(param)
            print("Data id:", meta.data_id)
            print("Owner id:", meta.owner_id)
            print("Uploaded at:", meta.create_time)
            print("Expires at:", meta.expire_time)

            # Download game file
            result = await store.get_object_infos([meta.data_id])
            result.results[0].raise_if_error()

            info = result.infos[0]
            url = "https://" + info.url
            headers = {h.key: h.value for h in info.headers}
            response = await http.get(url, headers=headers)
            response.raise_if_error()
            with open("game.bin", "wb") as f:
                f.write(response.body)
Example #12
0
from nintendo.nex import backend
from nintendo.games import Friends

import logging
logging.basicConfig(level=logging.INFO)

backend = backend.BackEndClient(Friends.ACCESS_KEY, Friends.NEX_VERSION,
                                backend.Settings("friends.cfg"))
backend.connect("127.0.0.1", 1223)
backend.login_guest()
backend.close()
Example #13
0
async def main():
    nas = nnas.NNASClient()
    nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
    nas.set_title(Friends.TITLE_ID_EUR, Friends.LATEST_VERSION)
    nas.set_locale(REGION, COUNTRY, LANGUAGE)

    access_token = await nas.login(USERNAME, PASSWORD)
    nex_token = await nas.get_nex_token(access_token.token,
                                        Friends.GAME_SERVER_ID)

    pid = await nas.get_pid(USERNAME)
    mii = await nas.get_mii(pid)

    s = settings.load("friends")
    s.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION)
    async with backend.connect(s, nex_token.host, nex_token.port) as be:
        async with be.login(str(nex_token.pid), nex_token.password) as client:
            nna_info = friends.NNAInfo()
            nna_info.principal_info.pid = pid
            nna_info.principal_info.nnid = USERNAME
            nna_info.principal_info.mii.name = mii.name
            nna_info.principal_info.mii.data = mii.data

            #NintendoPresenceV2 tells the server about your online status, which
            #game you're currently playing, etc. This will be shown to your friends
            #in their friend list (unless you disabled this feature).
            presence = friends.NintendoPresenceV2()

            friends_client = friends.FriendsClientV2(client)
            response = await friends_client.update_and_get_all_information(
                nna_info, presence, BIRTHDAY)

            if response.comment.text:
                print("Your status message: %s (last changed on %s)" %
                      (response.comment.text, response.comment.changed))
            else:
                print("You don't have a status message")

            if response.friends:
                print("Friends:")
                for friend in response.friends:
                    principal_info = friend.nna_info.principal_info
                    print("\tNNID:", principal_info.nnid)
                    print("\tName:", principal_info.mii.name)

                    presence = friend.presence
                    print("\tOnline:", ["No", "Yes"][presence.is_online])
                    if presence.game_key.title_id:
                        print("\tPlaying: %016X (v%i)" %
                              (presence.game_key.title_id,
                               presence.game_key.title_version))

                    if friend.comment.text:
                        print("\tStatus: %s (last changed on %s)" %
                              (friend.comment.text, friend.comment.changed))

                    print("\tFriend since:", friend.befriended)
                    print("\tLast online:", friend.last_online)
                    print("\t" + "-" * 40)
                print()
            else:
                print("You don't have any friends")

            if response.sent_requests:
                print("Friend requests sent:")
                print_requests(response.sent_requests)
            else:
                print("You haven't sent any friend requests")

            if response.received_requests:
                print("Friend requests received:")
                print_requests(response.received_requests)
            else:
                print("You haven't received any friend requests")

            if response.blacklist:
                print("Blacklist:")
                for item in response.blacklist:
                    principal_info = item.principal_info
                    print("\tWho: %s (%s)" %
                          (principal_info.nnid, principal_info.mii.name))
                    if item.game_key.title_id:
                        print("\tGame: %016X (%i)" %
                              (item.game_key.title_id,
                               item.game_key.title_version))
                    print("\tSince:", item.since)
                    print("\t" + "-" * 40)
            else:
                print("You haven't blacklisted any users")
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(SMM2.TITLE_ID, SMM2.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(SMM2.ACCESS_KEY, SMM2.NEX_VERSION, SMM2.CLIENT_VERSION)
    async with backend.connect(s, HOST, PORT) as be:
        async with be.login(str(user_id), auth_info=auth_info) as client:
            store = datastore.DataStoreClientSMM2(client)

            param = datastore.GetUserOrCourseParam()
            param.code = COURSE_ID
            param.course_option = datastore.CourseOption.ALL

            response = await store.get_user_or_course(param)
            course = response.course

            # Print information about the course
            print("Level info:")
            print("\tName:", course.name)
            print("\tDescription:", course.description)
            print("\tUploaded at:", course.upload_time)
            print("\tGame:", GameStyles[course.game_style])
            print("\tTheme:", CourseThemes[course.course_theme])
            print("\tDifficulty:", Difficulties[course.difficulty])
            print("\tFirst tag:", TagNames[course.tag1])
            print("\tSecond tag:", TagNames[course.tag2])
            print("\tWorld record:",
                  format_time(course.time_stats.world_record))
            print("\tNumber of comments:", course.comment_stats[0])

            # Request information about its uploader
            param = datastore.GetUsersParam()
            param.pids = [course.owner_id]

            response = await store.get_users(param)
            user = response.users[0]
            print("Uploader:")
            print("\tCode:", user.code)
            print("\tName:", user.name)
            print("\tCountry:", user.country)
            print("\tLast active:", user.last_active)

            # Download thumbnails
            await download_thumbnail(store, course.one_screen_thumbnail,
                                     "thumbnail_onescreen.jpg")
            await download_thumbnail(store, course.entire_thumbnail,
                                     "thumbnail_entire.jpg")

            # Download level file
            param = datastore.DataStorePrepareGetParam()
            param.data_id = course.data_id

            req_info = await store.prepare_get_object(param)
            response = await http.get(req_info.url)
            response.raise_if_error()
            with open("level.bin", "wb") as f:
                f.write(response.body)
Example #15
0
bits = dict(map(lambda a: a.split("="), resp.text.split("&")))
bits_dec = {}
for k in bits:
    bits_dec[k] = nintendo_base64_decode(bits[k])
host, port = bits_dec['locator'].decode().split(':')
port = int(port)

pid = str(identity['user_id'])
password = identity['password']
my_friendseed = identity['lfcs']

backend = backend.BackEndClient(friends.FriendsTitle.ACCESS_KEY,
                                friends.FriendsTitle.NEX_VERSION,
                                backend.Settings("friends.cfg"))
backend.connect(host, port)
backend.login(
    pid,
    password,
    auth_info=None,
    login_data=authentication.AccountExtraInfo(168823937, 2134704128, 0,
                                               bits['token']),
)

client = friends.Friends3DSClient(backend)
status = 'Seedbot - up for {}.\nGot {} FCs.'
fc_count = 0

#print(db.execute("select pid from friends").fetchall())

all = client.get_all_friends()
Example #16
0
from nintendo.nex import backend, authentication, datastore
from nintendo import account

PRINCIPAL_ID = "..." #PrincipalID
NEX_PASSWORD = "******" #Nex Password
NASC_REQUEST = "..." #Full NASC request for login; alternatively can login using NNID(?)

nex_account_details = nasc.login(NASC_REQUEST)

backend = backend.BackEndClient(
	'd6f08b40', # ACNL Nex Access Key
	31017, # Nex Version
	# backend.Settings("dream.cfg")
)
backend.connect(nex_account_details['host'], nex_account_details['port'])

login_info = authentication.AuthenticationInfo()
login_info.token = nex_account_details['token']
login_info.ngs_version = 3
login_info.token_type = 0
login_info.server_version = 2006

backend.login(PRINCIPAL_ID, NEX_PASSWORD, auth_info=login_info)

store = datastore.DataStoreClient(backend.secure_client)

get_param = datastore.DataStorePrepareGetParam()
get_param.data_id = 1206006	#This is dream Address 5D00-0012-66F6; 00001266F6 converted to decimal is 1206006; 5D is just a client side checksum(?) and not needed for downloads
get_param.lock_id = 0
get_param.persistence_target.owner_id = 0