Two hour refresh/login fails
I'll dive into more if I have some time, but I'm not making it past the two hour refresh/login (python app.py)... GUI still present and no errors display. Pretty sure same result running just cli.py, but I'd have to test again.
[Windows 10]
logs.txt:
1655351421.3865132: 'result'
1655351421.3865132: Login from file
1655351441.3685381: 'result'
1655351441.3685381: Login from file
1655351441.3685381: 'result'
1655351441.3685381: Login from file
1655351441.3685381: Login from Flapg/s2s
1655351441.3685381: 'result'
w/ some added prints:
1655358158.8690448 Checked time at start of update(): 7220.071228981018
1655351441.3685381 log(): 'result'
Attempting to refresh token...
1655351441.3685381 log(): Login from file
Time check is: 7220.273142576218
We didn't pass the 7170 check.
1655351441.3685381 log(): Login from Flapg/s2s
s2s response: b'{"hash":"xxx"}'
Flapg response: b'{"result":{"f":"xxx","p1":"xxx","p2":"xxx","p3":"xxx"}}'
Before loginToAccount.
After loginToAccount.
1655351441.3685381 log(): 'result'
I'm confused- from what it looks like to me, it's working fine? Does the app crash/stop working? From what I can tell, after the time check is 7220, the app attempts to login from file, fails, then logins from Flapg/s2s, thus refreshing the session. Is the issue that the app fails to refresh if the time check is about to expire, and instead relies on the error of token expiration in order to refresh?
Sorry, no visible crash per say. The status checks/loop simply stops after the above takes place. Fix is to restart the app
Posting from test I left up last night... Will have to dive into more later.
But the Flagp response before we dive into loginToAccount appears to renew the f token, but not p1 or p3
Flapg response: b'{"result":{"f":"NEW","p1":"OLD","p2":"1655464973","p3":"OLD"}}'
'parameter': {
'f': 'NEW',
'naIdToken': 'OLD',
...
}
This is where the app stops updating:
response = requests.post(self.url + route, headers = self.headers, json = body)
print("loginToAccount response.text is: ", response.text, flush=True)
{"status": 9404, "errorMessage": "Token expired.", "correlationId": "xxx"}
But the
Flagpresponse before we dive intologinToAccountappears to renew theftoken, but notp1orp3Flapg response: b'{"result":{"f":"NEW","p1":"OLD","p2":"1655464973","p3":"OLD"}}'
p1, p2 and p3 are just the parameters that flapg passes to the gen_audio_h/gen_audio_h2 function in Nintendo's app - exactly as they are passed to the flapg API.
I have no idea what those logs mean but I think I see the issue here (in client/api/__init__.py):
-
APIis initialised once at the start of the process's lifetime. -
APIcallsNintendo.getServiceTokento authenticate to the Nintendo Account authentication server (Nintendo Account authentication). - Later on,
API.updateLoginis called, which callsLogin.loginToAccountto authenticate to coral (Nintendo Switch Online app authentication), using the Nintendo Account token obtained earlier.
When the NSO app token expires, API.updateLogin is called again, which calls Login.loginToAccount with the same Nintendo Account token that was obtained when the app was first started (and request_id, which should probably just be generated when actually calling the flapg API like the timestamp). The NSO app token is valid for 2 hours while the Nintendo Account token is only valid for 15 minutes, so it definitely needs to be refreshed here.
Not sure why failing to renew the NSO app token doesn't cause the app to exit...
Also it looks like Login.loginToAccount is called with the access_token from the Nintendo Account token response, when the app uses the id_token - I don't know why Nintendo accepts that?
This was fixed in #22. Thank you to everyone who helped with this error!