samuelthomas2774/nxapi

User data not including presence

samuelthomas2774 opened this issue · 3 comments

/v3/Account/Login, /v3/Account/GetToken and /v3/User/ShowSelf currently seem to be returning incorrect presence data. This object is always returned (which looks the same as the presence object for users who have never been online, or are not sharing their presence with you):

"presence": {
    "state": "OFFLINE",
    "updatedAt": 0,
    "logoutAt": 0,
    "game": {}
}

/v3/Friend/List still returns correct presence data.

NSO-RPC users have confirmed they also don't get their own presence data anymore. (#13, #11 comment)

I don't think this will be fixed any time soon. Most likely Nintendo has stopped providing the current user's presence data intentionally, or there's an issue or unintentional change with the API that they don't care about as the app doesn't show the current user's presence anyway.

  • If the user's own presence data was removed on purpose, why not just remove the presence object entirely from the response to those endpoints?

    TODO: check if the app reads this data, even if it doesn't use it anywhere. This could mean Nintendo would have to update the app to remove a feature that they apparently never added.

    Modifying the response to remove the presence object doesn't affect the app.

  • Also if this was removed on purpose, why? To stop anyone using nxapi or NSO-RPC to connect to Discord specifically? Or because Nintendo noticed more requests to /v3/User/ShowSelf? (Or increased login attempts while NSO-RPC did that?) Or just an (unnecessary) optimisation as it wasn't used anyway?


This change means that a separate account (with your own account added as a friend) is required to fetch your own presence.

For nxapi:

  1. Add an account that's friends with you to nxapi using nxapi nso auth.

    If you don't have access to an account you can use:

    1. Create a new user on your Nintendo Switch and link a new Nintendo Account.
    2. Add that user as your friend, and make sure it can see your presence.
    3. (Optionally) delete the new user from your console (not the Nintendo Account). (You might want to keep if there if you want to add other users as friends to fetch their presence as well.)

    If you can, to reduce requests to Nintendo, set up nxapi's znc API proxy server to allow multiple other users to fetch their presence at the same time. Then use the --presence-url option when running nxapi nso presence.

  2. Run nxapi users list to find:

    • The Nintendo Account ID (first column titled ID) of the new automated account, and...
    • The Network Service Account ID (fifth column titled NSA ID) of your own account that you want to fetch the presence of (the same NSA ID should be listed when running nxapi nso friends as the automated account).
  3. When running nxapi nso presence, set the --user option to the Nintendo Account ID of the new automated account, and set the --friend-nsaid option to the Network Service Account ID of the user you want to share presence of.

    If you want to share your friend code in Discord, you'll have to specify it manually after the --friend-code option.

For NSO-RPC users, watch this issue and wait for an update: MCMi460/NSO-RPC#13


Other options:

  • If you have custom firmware, I'd recommend using one of the tools that can fetch your presence directly from your console. This avoids requests to Nintendo entirely (and works if your console is banned or not up to date).
  • Parental Controls data, but not really as it updates way too slow, as it's meant to show past activity. nxapi's Discord integration and NSO-RPC are only really feasible as znc provides this data in real time.

@MCMi460 You'll need to add something similar for NSO-RPC so a friend can be selected to share their presence (I'm guessing that was your original plan as well).

Also I've published the script to export my Discord client IDs, you can fetch them from the same links I shared here, or if you install nxapi from source you can run nxapi util export-discord-titles. (Anyone else that wants to use these Discord applications you must ask me first.)

Looking into this, I've noticed something, if you ever go into the account settings of your console as soon as you've started a game, it will still say that you're Offline. Play any game for a about a minute, then check back into account settings on the console, and it'll show your current game status.

e.g.

I've been playing a game for more than a minute while on my wifi...
image

But, turn off the internet, and go back into the accounts settings, and now it shows offline, even though I am for sure still playing the game.
image

What this basically shows is that there is still someway to grab self-presence data. Nintendo's recent change wasn't a break, but a deliberate change to stop the NSO app from grabbing self-presence data, since it never displayed it in app.

In any case, this means there should still be a way to obtain self-presence data (without a second friend account), we just need to find the "new" (undiscovered) API request data that comes directly from the console, most likely via some network packet inspection between the router and the console.

I have a hunch that the additional data that gets passed along to the API (to request self-presence data), likely requires one or more console identifiers (probably a hardware ID and OS version).

For example, if we were to use a different user-agent to access the same API endpoint (which I can tell from my packet sniffing on my own network that the Switch does connect to the same endpoint from time to time), it's likely that if we use the system user-agent (see https://switchbrew.org/wiki/Network#User-Agent ):

snprintf(..., "User-Agent: NintendoSDK Firmware/%s-%u (platform:%s; did:%016llx; eid:%s)", <string at sysver+0x68>, {u32 from sysver+4}, "NX", DeviceId, {GetEnvironmentIdentifier output});
 
snprintf(..., "User-Agent: NintendoSDK Firmware/%s-%u (platform:%s; eid:%s)", <string at sysver+0x68>, {u32 from sysver+4}, "NX", DeviceId, {GetEnvironmentIdentifier output});

... then we may be able to retrieve self-presence data... But I don't currently possess the knowledge or cognizance to go about working on that.

turn off the internet, and go back into the accounts settings, and now it shows offline, even though I am for sure still playing the game.
...
What this basically shows is that there is still someway to grab self-presence data

You're right that there is (likely) a way to still get self presence data however I don't believe this test is a good proof of that. Showing as offline when you have no internet connection is expected behavior and the Switch likely just displays this the moment it detects there's no internet connection, not because of some failed self-presence request

The Switch gets user account information from the BAAS server. However accessing the Switch's servers in this way is very risky. Any tiny mishap that doesn't look identical to how a console would make requests (even down to the order the request headers are in) can, and will, lead to a ban

https://e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com/1.0.0/users/{userID} will return an object containing a presence field, which is an object containing state (OFFLINE, INACTIVE, ONLINE or PLAYING), logout and update time stamps, and an extras field. This extras field contains a appInfo:appId field which is the title ID of the playing title

The users account ID is given during login, which you'd have to do also using the BAAS server. And in order to do that you'll have to authenticate with the DAUTH server. You're going to essentially have to migrate entirely to the Switch's account API to get self presence to work again

Though I have not actually verified if that endpoint works for getting your own user data, I haven't tried it yet but I don't see why it wouldn't

You can find more information about the Switch servers and their API here https://nintendo-wiki.pretendo.network/docs/servers. This is a re-hosted mirror of https://github.com/kinnay/NintendoClients/wiki which just contains some more updated information for some stuff, maintained by us at Pretendo Network, but the Switch docs should be identical. The original wiki also has a Python client to interact with these servers safely, found here https://github.com/kinnay/NintendoClients/blob/master/nintendo/baas.py