nxapi icon indicating copy to clipboard operation
nxapi copied to clipboard

Automatically retry on `9403 Invalid token`

Open eai04191 opened this issue 2 years ago • 3 comments

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.

eai04191 avatar Sep 28 '22 14:09 eai04191

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

  • https://github.com/samuelthomas2774/nxapi/discussions/10#discussioncomment-3464443

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?

samuelthomas2774 avatar Oct 09 '22 01:10 samuelthomas2774

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.

ShiroBlank avatar Oct 16 '22 14:10 ShiroBlank

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 avatar Oct 16 '22 14:10 samuelthomas2774

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.

samuelthomas2774 avatar Dec 19 '22 01:12 samuelthomas2774