samuelthomas2774 / nxapi

Nintendo Switch Online/Parental Controls app APIs. Show your Nintendo Switch presence in Discord, get friend notifications on desktop, and download and access SplatNet 2, NookLink, SplatNet 3 and Parental Controls data. Mirror of https://gitlab.fancy.org.uk/samuel/nxapi.git.
GNU Affero General Public License v3.0
413 stars 34 forks source link

Automatically retry on `9403 Invalid token` #26

Closed eai04191 closed 1 year ago

eai04191 commented 1 year ago

image

I don't know if it's because of the server or the network/ISP I'm using, but the nxapi-app often fails to get the token and creates a dialog each time. This can happen several times an hour, and pressing retry does nothing wrong, but it's annoying. Retrying automatically for retryable errors and popping up the error only if it still can't be recovered would improve the experience. Thanks.

samuelthomas2774 commented 1 year ago

This is because of the changes to the f token validation a few weeks ago:

As this token is generated in a native library in the official app no one really knows how it works, and there must still be something else that changed that's causing imink/flapg/nxapi/nsotokengen to sometimes not generate valid tokens.

I have thought about retrying automatically once for this as that usually works, but a few people have reported requiring a lot more attempts before authenticating works. Unless I or someone else figures out a better fix I'll probably still do this for the app, but that doesn't really fix the issue here.

This can happen several times an hour, and pressing retry does nothing wrong, but it's annoying.

This should only happen every 2 hours (for each account with active monitors) as that's how long the token is valid for. Is this happening more frequently for you?

ShiroBlank commented 1 year ago

I'm facing the same issue, but in addition I am also seeing an error popup constantly when having auto refresh enabled (and disabled). image auto-retrying all these errors would be a great QOL change.

samuelthomas2774 commented 1 year ago

I actually just added EAI_AGAIN as an error code it will auto-retry for yesterday (https://github.com/samuelthomas2774/nxapi/commit/02e49a9554e9b434be659840635f174a30869d6b). Let me know if you see any other codes for temporary errors. All errors for the main window refreshes already just appear as a warning icon, the error dialog is just for friend notifications/Discord presence.

For the 9403 Invalid token errors: @JoneWang is updating the imink API later to hopefully try to resolve the issue of f tokens often being rejected. If this helps I'd prefer not to auto retry on those errors in case Nintendo makes any changes to the API again.

samuelthomas2774 commented 1 year ago

Closing as issues with f token generation from 23/08/2022 appear to be resolved now.

Handling of errors updating presence data will be moved to #41.